mirror of https://github.com/MilkBowl/Vault.git
Compare commits
42 Commits
adf1be3157
...
5032b21d9f
Author | SHA1 | Date |
---|---|---|
leonardo-dgs | 5032b21d9f | |
ILikePlayingGames | e2f919793f | |
Morgan | b2cc6bef13 | |
Morgan | 9e47e33a04 | |
Morgan | c553bda7a2 | |
Llm Dl | 31fd7b172a | |
Llm Dl | 45bcfa032a | |
Ricardo Boss | 4270d00060 | |
leonardo-dgs | d1bae78c8c | |
leonardo-dgs | 5c33e2a58b | |
leonardo-dgs | 4fe21d613c | |
Geolykt | 9ec25918cc | |
Jack | a955144229 | |
Morgan | 516c0edc96 | |
leonardo-dgs | ce600deed5 | |
leonardo-dgs | 38dad24f01 | |
Chen Zhang | 5720e5393f | |
Nick Minkler | 1030a2f6eb | |
Nick Minkler | 6df7d60dfb | |
TheBlueKingLP | da1d5e791e | |
Nick Minkler | ad2972c037 | |
montlikadani | 80475174cf | |
Nick Minkler | 6a0340cb29 | |
Nick Minkler | 8529e021e5 | |
MrIvanPlays | 4d33f15150 | |
Nick Minkler | 8dba2a5744 | |
Nick Minkler | f9f6281077 | |
Nick Minkler | 60e02f2c03 | |
Tim "timmyRS" Speckhals | a9272ee405 | |
Sleaker | 24ecef0ba0 | |
Sleaker | 8de3760c0e | |
Sleaker | 7a691830e0 | |
Sleaker | 62b367bf31 | |
Sleaker | f4aac9b9f6 | |
DoNotSpamPls | 204319e3b8 | |
BrightSkyz | 1399fb150e | |
Niklas Linz | dcbc47a886 | |
Nick Minkler | 4698ce6aa8 | |
montlikadani | e62e2381d9 | |
Nick Minkler | 7cc4eee3e7 | |
Nick Minkler | 83803ca08a | |
Nick Minkler | 48dc60d94f |
|
@ -0,0 +1,2 @@
|
|||
service_name: travis-pro
|
||||
repo_token: ${env.COVERALLS_REPO_TOKEN}
|
17
.travis.yml
17
.travis.yml
|
@ -1,8 +1,21 @@
|
|||
language: java
|
||||
jdk: [ openjdk7 ]
|
||||
jdk: [ openjdk8 ]
|
||||
sudo: false
|
||||
env:
|
||||
global:
|
||||
- secure: "WGObsHmjnqn5e0nbXLGetwpUHU0UgvNk02+f0m3jIS7hSdBy5m1JK2K6NXV13brY0C9i0DLy0e7JKabqmqTxI94dT0LrYBxcvfmtZ/7PujOn/D9CzVimGj6g20hBDYwAXL6KAIR7JL8qexQBwIkVZPdwaA+k+UHLM9XVoIQdFgU="
|
||||
- secure: "XfBov3Z4Rk2AvS1v7o31Qr2XrO/oqQvl+Eksx9DO3XbGcLjT9wfGxGcYgP9IJO+Aa5AQo3Xud7EV4gqNpMa2PByzDdgg/nfyqSvrRvsG2aH1zm5N5bAHxCVlPimVdNtyeub6QBPCIGaWBp1R8x3Ak7F79mA5BdJuT9j5FBogC5U="
|
||||
script: .utility/do-build.sh
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
script: .utility/build.sh
|
||||
on:
|
||||
all_branches: true
|
||||
- provider: script
|
||||
script: .utility/deploy.sh
|
||||
on:
|
||||
branch: master
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.m2
|
||||
|
|
|
@ -4,11 +4,5 @@ then
|
|||
echo 'Travis can only publish docs for release builds.'
|
||||
return 0
|
||||
fi
|
||||
if [[ $TRAVIS_PULL_REQUEST == true || "$TRAVIS_BRANCH" != "master" ]]
|
||||
then
|
||||
mvn test
|
||||
else
|
||||
mvn clean deploy --settings .utility/settings.xml
|
||||
fi
|
||||
|
||||
mvn test -DrepoToken=$COVERALLS_REPO_TOKEN
|
||||
exit $?
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
if [[ "$TRAVIS_REPO_SLUG" != "MilkBowl/Vault" ]]
|
||||
then
|
||||
echo 'Travis can only publish docs for release builds.'
|
||||
return 0
|
||||
fi
|
||||
mvn clean deploy --settings .utility/settings.xml
|
||||
exit $?
|
126
README.md
126
README.md
|
@ -1,47 +1,46 @@
|
|||
# Vault - Abstraction Library for Bukkit - ![Travis-ci](https://travis-ci.org/MilkBowl/Vault.svg?branch=master)
|
||||
# Vault - Abstraction Library for Bukkit - [![Build Status](https://app.travis-ci.com/MilkBowl/Vault.svg?branch=master)](https://app.travis-ci.com/MilkBowl/Vault)
|
||||
|
||||
## For Developers:
|
||||
Please see the [VaultAPI](http://www.github.com/MilkBowl/VaultAPI) page for
|
||||
information on developing with Vault's API. In the past you would use the same
|
||||
artifact as servers installed, but the API has now been split from the main
|
||||
project and is under a different artifact name. Please make sure you accommodate
|
||||
for this change in your build process.
|
||||
Please see the [VaultAPI](https://www.github.com/MilkBowl/VaultAPI) page for
|
||||
information on developing with Vault's API. In the past, you would use the same
|
||||
artifact as servers installed, but the API has now been split from the main
|
||||
project and is under a different artifact name. Please make sure you accommodate
|
||||
this change in your build process.
|
||||
|
||||
## Installing
|
||||
Installing Vault is as simple as copying the provided "Vault.jar" to your
|
||||
"<bukkit-install-dir>/plugins" directory and the rest is automatic! If you
|
||||
"<bukkit-install-dir>/plugins" directory, and the rest is automatic! If you
|
||||
wish to perform configuration changes, this can be done via a configuration
|
||||
file but should not be necessary in most cases. See the "Advanced
|
||||
file but should not be necessary in most cases. See the "Advanced
|
||||
Configuration" section for more information.
|
||||
|
||||
|
||||
## Why Vault?
|
||||
I have no preference which library suits your plugin and development efforts
|
||||
best. Really, I thought a central suite (rather...Vault) of solutions was the
|
||||
the proper avenue than focusing on a single category of plugin. That's where
|
||||
best. Really, I thought a central suite (rather...Vault) of solutions was the
|
||||
proper avenue than focusing on a single category of plugin. That's where
|
||||
the idea for Vault came into play.
|
||||
|
||||
So, what features do I _think_ you'll like the most?
|
||||
|
||||
* No need to include my source code in your plugin
|
||||
All of Vault is run in its own plugin, so all you need to do is obtain an
|
||||
instance of it! This simplifies issues with multiple plugins using the same
|
||||
namespaces. Just simply add Vault.jar to your download zip file!
|
||||
* Broad range of supported plugins
|
||||
I wanted an abstraction layer not only for Economic plugins but also
|
||||
Permission plugins as well. The future will likely add more, but what
|
||||
types, I have yet to decide, let me know!
|
||||
* Choice!
|
||||
That's half the fun of Bukkit, we get to choose what to use! More choice
|
||||
has never hurt developers so here's to choice!
|
||||
* No need to include my source code in your plugin
|
||||
All of Vault is run in its own plugin, so all you need to do is obtain an
|
||||
instance of it! This simplifies issues with multiple plugins using the same
|
||||
namespaces. Just simply add Vault.jar to your download zip file!
|
||||
* Broad range of supported plugins
|
||||
I wanted an abstraction layer not only for Economic plugins but also
|
||||
Permission plugins as well.
|
||||
* Choice!
|
||||
That's half the fun of Bukkit! We get to choose what to use. More choice
|
||||
has never hurt developers, so here's to choice!
|
||||
|
||||
|
||||
## Permissions
|
||||
* vault.admin
|
||||
- Determines if a player should recieve the update notices
|
||||
* vault.admin
|
||||
- Determines if a player should receive the update notices
|
||||
|
||||
## License
|
||||
Copyright (C) 2011 Morgan Humes <morgan@lanaddict.com>
|
||||
Copyright (C) 2011-2018 Morgan Humes <morgan@lanaddict.com>
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
|
@ -50,85 +49,42 @@ the Free Software Foundation, either version 3 of the License, or
|
|||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
## Building
|
||||
Vault comes with all libraries needed to build from the current branch and
|
||||
also comes with an Apache Ant build file (build.xml).
|
||||
also comes with an Apache Ant build file (build.xml) and a Maven build file
|
||||
(pom.xml). Maven is currently the preferred build method.
|
||||
|
||||
|
||||
## Dependencies
|
||||
Because Vault provides a bridge to other plugins, their binaries will be
|
||||
required to build from. To ease this, they have been included in the lib
|
||||
folder and will be updated from time to time. For plugin developers, it
|
||||
is not necessary to use these libraries when implementing Vault. You will
|
||||
required to build from. To ease this, they have been included in the lib
|
||||
folder and will be updated from time to time. For plugin developers, it
|
||||
is not necessary to use these libraries when implementing Vault. You will
|
||||
only need to compile against Vault.
|
||||
|
||||
|
||||
## Supported Plugins
|
||||
Vault provides abstraction for the following categories and plugins. If you
|
||||
have your own plugin that you believe should be supported, fork Vault or create
|
||||
a patch with the necessary changes. Additionally you can create an issue on
|
||||
Github and we'll get to it at our convenience.
|
||||
|
||||
* Economy
|
||||
- 3co (http://forums.bukkit.org/threads/22461/)
|
||||
- AEco
|
||||
- BOSEconomy 6 (http://forums.bukkit.org/threads/19025/)
|
||||
- BOSEconomy 7
|
||||
- CommandsEX Economy (http://dev.bukkit.org/server-mods/commandsex/)
|
||||
- CraftConomy2 (http://dev.bukkit.org/server-mods/craftconomy/)
|
||||
- CraftConomy3 (http://dev.bukkit.org/server-mods/craftconomy/)
|
||||
- CurrencyCore (http://dev.bukkit.org/server-mods/currency/)
|
||||
- Dosh
|
||||
- EconXP (http://dev.bukkit.org/server-mods/econxp/)
|
||||
- Essentials Economy (http://forums.bukkit.org/threads/15312/)
|
||||
- eWallet (http://dev.bukkit.org/server-mods/ewallet/)
|
||||
- GoldIsMoney
|
||||
- GoldIsMoney2
|
||||
- Gringotts
|
||||
- iConomy 4 (http://forums.bukkit.org/threads/40/)
|
||||
- iConomy 5 (http://forums.bukkit.org/threads/40/)
|
||||
- iConomy 6 (http://forums.bukkit.org/threads/40/)
|
||||
- McMoney
|
||||
- Miconomy
|
||||
- MineConomy (http://dev.bukkit.org/server-mods/mineconomy/)
|
||||
- MineFaconomy2
|
||||
- MultiCurrency
|
||||
- SDFEconomy
|
||||
- TAEcon
|
||||
- XPBank
|
||||
Vault provides abstraction for the following categories and plugins. If
|
||||
you have your own plugin that you believe should be supported, you'll need
|
||||
to add your own connector within your plugin as Vault no longer maintains
|
||||
new plugin connectors.
|
||||
|
||||
* Permissions
|
||||
- bPermissions
|
||||
- bPermissions 2 (http://dev.bukkit.org/server-mods/bpermissions/)
|
||||
- DroxPerms
|
||||
- Group Manager (Essentials) (http://forums.bukkit.org/threads/15312/)
|
||||
- OverPermissions (http://dev.bukkit.org/bukkit-plugins/overpermissions/)
|
||||
- Permissions 3 (http://forums.bukkit.org/threads/18430/)
|
||||
- PermissionsBukkit
|
||||
- Permissions Ex (http://forums.bukkit.org/threads/18140/)
|
||||
- Privileges
|
||||
- rscPermissions
|
||||
- SimplyPerms
|
||||
- bPermissions 2 (https://dev.bukkit.org/projects/bpermissions)
|
||||
- Group Manager (Essentials) (https://forums.bukkit.org/threads/15312/)
|
||||
- LuckPerms (https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-plugin.28140/)
|
||||
- Permissions Ex (PEX) (https://forums.bukkit.org/threads/18140/)
|
||||
- SuperPerms (Bukkit's default)
|
||||
- TotalPermissions (http://dev.bukkit.org/bukkit-mods/totalpermissions)
|
||||
- XPerms
|
||||
- zPermissions
|
||||
|
||||
* Chat
|
||||
- bPermissions
|
||||
- Group Manager (Essentials)
|
||||
- iChat
|
||||
- mChat
|
||||
- mChatSuite
|
||||
- OverPermissions
|
||||
- Permissions3
|
||||
- PEX
|
||||
- rscPermissions
|
||||
- TotalPermissions
|
||||
- Group Manager (Essentials) (https://forums.bukkit.org/threads/15312/)
|
||||
- LuckPerms (https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-plugin.28140/)
|
||||
- Permissions Ex (PEX) (https://forums.bukkit.org/threads/18140/)
|
||||
- zPermissions
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/DigiCoin.jar
BIN
lib/DigiCoin.jar
Binary file not shown.
BIN
lib/Dosh.jar
BIN
lib/Dosh.jar
Binary file not shown.
BIN
lib/EconXP.jar
BIN
lib/EconXP.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/KPerms.jar
BIN
lib/KPerms.jar
Binary file not shown.
BIN
lib/McMoney.jar
BIN
lib/McMoney.jar
Binary file not shown.
BIN
lib/MiConomy.jar
BIN
lib/MiConomy.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/Register.jar
BIN
lib/Register.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/TAEcon.jar
BIN
lib/TAEcon.jar
Binary file not shown.
Binary file not shown.
BIN
lib/XPBank.jar
BIN
lib/XPBank.jar
Binary file not shown.
BIN
lib/Xperms.jar
BIN
lib/Xperms.jar
Binary file not shown.
Binary file not shown.
BIN
lib/eWallet.jar
BIN
lib/eWallet.jar
Binary file not shown.
BIN
lib/iChat.jar
BIN
lib/iChat.jar
Binary file not shown.
BIN
lib/iConomy6.jar
BIN
lib/iConomy6.jar
Binary file not shown.
BIN
lib/mChat.jar
BIN
lib/mChat.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -3,6 +3,7 @@ version: ${project.version}-b${env.TRAVIS_BUILD_NUMBER}
|
|||
description: ${project.description}
|
||||
authors: [cereal, Sleaker, mung3r]
|
||||
website: ${project.url}
|
||||
api-version: 1.13
|
||||
|
||||
main: ${mainClass}
|
||||
load: startup
|
||||
|
@ -12,10 +13,12 @@ commands:
|
|||
description: Displays information about Vault
|
||||
usage: |
|
||||
/<command> - Displays Vault information
|
||||
permission: vault.admin
|
||||
vault-convert:
|
||||
description: Converts all data in economy1 and dumps it into economy2
|
||||
usage: |
|
||||
/<command> [economy1] [economy2]
|
||||
permission: vault.admin
|
||||
permissions:
|
||||
vault.admin:
|
||||
description: Notifies the player when vault is in need of an update.
|
||||
|
|
343
pom.xml
343
pom.xml
|
@ -1,23 +1,21 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<bukkitVersion>1.8-R0.1-SNAPSHOT</bukkitVersion>
|
||||
<bukkitVersion>1.13.1-R0.1-SNAPSHOT</bukkitVersion>
|
||||
<mainClass>${project.groupId}.${project.artifactId}</mainClass>
|
||||
<api.version>1.6</api.version>
|
||||
<api.version>1.7</api.version>
|
||||
</properties>
|
||||
|
||||
<!-- Project information -->
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>${api.version}.6</version>
|
||||
<version>${api.version}.3</version>
|
||||
<name>Vault</name>
|
||||
<url>http://dev.bukkit.org/server-mods/vault/</url>
|
||||
<description>Vault is a Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.
|
||||
|
||||
Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms, bPerms2, SimplyPerms, DroxPerms, zPermissions, rscPermissions, KPerms, Starburst, iConomy (4/5/6) BOSEconomy *6/7), EssentialsEcon, 3Co, MultiConomy, MineConomy, EconXP, eWallet, CurrencyCore, XPBank, CraftConomy, AEco, SDFEconomy, TAEcon, and OverPermissions</description>
|
||||
<url>https://dev.bukkit.org/projects/vault</url>
|
||||
<description>Vault is a Chat, Permissions & Economy API to allow plugins to more easily hook into these systems without needing to hook each individual system themselves.</description>
|
||||
|
||||
|
||||
|
||||
|
@ -61,18 +59,14 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>greatman-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>escapecraft-repo</id>
|
||||
<url>http://dev.escapecraft.com/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
|
@ -87,98 +81,9 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<version>${api.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.bleedobsidian.miconomy</groupId>
|
||||
<artifactId>MiConomy</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/MiConomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.hydrox.bukkit</groupId>
|
||||
<artifactId>DroxPerms</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.coniin.plugins.minefaconomy</groupId>
|
||||
<artifactId>MineFaConomy</artifactId>
|
||||
<version>0.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Minefaconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.krinsoft</groupId>
|
||||
<artifactId>Privileges</artifactId>
|
||||
<version>1.8.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Privileges.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>is.currency</groupId>
|
||||
<artifactId>Currency</artifactId>
|
||||
<version>0.61</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/CurrencyCore.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.igwb.GoldenChest</groupId>
|
||||
<artifactId>GoldenChestEconomy</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/GoldenChestEconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.flobi.GoldIsMoney2</groupId>
|
||||
<artifactId>GoldIsMoney</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/GoldIsMoney2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cosine.boseconomy.BOSEconomy</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>0.7.3.1a</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/BOSEconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.bananaco.permissions.Permissions</groupId>
|
||||
<artifactId>bPermissions</artifactId>
|
||||
<version>2.0.9a</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bpermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.sebc722</groupId>
|
||||
<artifactId>xPerms</artifactId>
|
||||
<version>1.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Xperms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ca.agnate.EconXP.EconXP</groupId>
|
||||
<artifactId>EconXP</artifactId>
|
||||
<version>0.4.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/EconXP.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.earth2me.essentials.Essentials</groupId>
|
||||
<artifactId>Essentials</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Essentials.jar</systemPath>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.anjocaido.groupmanager.GroupManager</groupId>
|
||||
|
@ -188,94 +93,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/EssentialsGroupManager.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ethan.eWallet.ECO</groupId>
|
||||
<artifactId>eWallet</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/eWallet.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>boardinggamer.mcmoney</groupId>
|
||||
<artifactId>McMoney</artifactId>
|
||||
<version>1.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/McMoney.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.TheDgtl.iChat.iChat</groupId>
|
||||
<artifactId>iChat</artifactId>
|
||||
<version>2.5.7</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/iChat.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iCo6.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>6.0.9b</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/iConomy6.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.mirelatrue.xpbank.XPBank</groupId>
|
||||
<artifactId>XPBank</artifactId>
|
||||
<version>0.9</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/XPBank.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.D3GN.MiracleM4n.mChat.mChat</groupId>
|
||||
<artifactId>mChat</artifactId>
|
||||
<version>1.8.5</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/mChat.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>in.mDev</groupId>
|
||||
<artifactId>mChatSuite</artifactId>
|
||||
<version>DEV-b275</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/mChatSuite.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mjolnir.mineconomy.MineConomy</groupId>
|
||||
<artifactId>MineConomy</artifactId>
|
||||
<version>1.6</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/MineConomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ashtheking.currency.Currency</groupId>
|
||||
<artifactId>MultiCurrency</artifactId>
|
||||
<version>0.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/MultiCurrency.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.bukkit.Permissions.Permissions</groupId>
|
||||
<artifactId>Permissions</artifactId>
|
||||
<version>3.1.6</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Permissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.platymuus.bukkit.permissions.PermissionsPlugin</groupId>
|
||||
<artifactId>PermissionsBukkit</artifactId>
|
||||
<version>2.3</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/PermissionsBukkit.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.tehkode</groupId>
|
||||
<artifactId>PermissionsEx</artifactId>
|
||||
|
@ -292,60 +109,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/bpermissions25.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.dthielke.starburst</groupId>
|
||||
<artifactId>Starburst</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Starburst.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nijikokun.register</groupId>
|
||||
<artifactId>Register</artifactId>
|
||||
<version>1.5</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Register.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.greatman.Craftconomy</groupId>
|
||||
<artifactId>Craftconomy</artifactId>
|
||||
<version>2.3.5</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Craftconomy.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.greatmancode</groupId>
|
||||
<artifactId>craftconomy3</artifactId>
|
||||
<version>3.2.2-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.crystalyx.bukkit.simplyperms</groupId>
|
||||
<artifactId>SimplyPerms</artifactId>
|
||||
<version>1.6.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/SimplyPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>Gringotts</groupId>
|
||||
<artifactId>Gringotts</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Gringotts.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gravypod.Dosh</groupId>
|
||||
<artifactId>Dosh</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/Dosh.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.zathrus_writer.commandsex</groupId>
|
||||
<artifactId>CommandsEX</artifactId>
|
||||
|
@ -354,62 +117,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/CommandsEX.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.omwah</groupId>
|
||||
<artifactId>SDFEconomy</artifactId>
|
||||
<version>0.2.2</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/SDFEconomy-0.2.2.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ae97</groupId>
|
||||
<artifactId>TotalPermissions</artifactId>
|
||||
<version>0.3.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/TotalPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.simsonic</groupId>
|
||||
<artifactId>rscPermissions</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/rscPermissions.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.teamalpha.taecon</groupId>
|
||||
<artifactId>TAEcon</artifactId>
|
||||
<version>0.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/TAEcon.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>KPerms</groupId>
|
||||
<artifactId>KPerms</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/KPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.uk.silvania.cities.digicoin</groupId>
|
||||
<artifactId>DigiCoin</artifactId>
|
||||
<version>0.1</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/DigiCoin.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.overmc</groupId>
|
||||
<artifactId>overpermissions</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<optional>true</optional>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/overpermissions-2.0.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -428,22 +135,30 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.0.2</version>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>3.1.0</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>net.milkbowl.vault:VaultAPI</include>
|
||||
<include>org.bstats</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>net.milkbowl.vault.metrics</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -454,6 +169,14 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eluder.coveralls</groupId>
|
||||
<artifactId>coveralls-maven-plugin</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<configuration>
|
||||
<repoToken>${env.COVERALLS_REPO_TOKEN}</repoToken>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -1,809 +0,0 @@
|
|||
package net.milkbowl.vault;
|
||||
|
||||
/*
|
||||
* Copyright 2011 Tyler Blair. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and contributors and should not be interpreted as representing official policies,
|
||||
* either expressed or implied, of anybody else.
|
||||
*/
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 8;
|
||||
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://report.mcstats.org";
|
||||
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/plugin/%s";
|
||||
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private static final int PING_INTERVAL = 15;
|
||||
|
||||
/**
|
||||
* The plugin this metrics submits for
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final File configurationFile;
|
||||
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private final String guid;
|
||||
|
||||
/**
|
||||
* Debug mode
|
||||
*/
|
||||
private final boolean debug;
|
||||
|
||||
/**
|
||||
* Lock for synchronization
|
||||
*/
|
||||
private final Object optOutLock = new Object();
|
||||
|
||||
/**
|
||||
* The scheduled task
|
||||
*/
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
// load the config
|
||||
configurationFile = getConfigFile();
|
||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
configuration.addDefault("debug", false);
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://mcstats.org").copyDefaults(true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
debug = configuration.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
public void findCustomData() {
|
||||
// Create our Economy Graph and Add our Economy plotters
|
||||
Graph econGraph = createGraph("Economy");
|
||||
RegisteredServiceProvider<Economy> rspEcon = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
Economy econ = null;
|
||||
if (rspEcon != null) {
|
||||
econ = rspEcon.getProvider();
|
||||
}
|
||||
final String econName = econ != null ? econ.getName() : "No Economy";
|
||||
econGraph.addPlotter(new Metrics.Plotter(econName) {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Create our Permission Graph and Add our permission Plotters
|
||||
Graph permGraph = createGraph("Permission");
|
||||
final String permName = Bukkit.getServer().getServicesManager().getRegistration(Permission.class).getProvider().getName();
|
||||
permGraph.addPlotter(new Metrics.Plotter(permName) {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// Create our Chat Graph and Add our chat Plotters
|
||||
Graph chatGraph = createGraph("Chat");
|
||||
RegisteredServiceProvider<Chat> rspChat = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
|
||||
Chat chat = null;
|
||||
if (rspChat != null) {
|
||||
chat = rspChat.getProvider();
|
||||
}
|
||||
final String chatName = chat != null ? chat.getName() : "No Chat";
|
||||
// Add our Chat Plotters
|
||||
chatGraph.addPlotter(new Metrics.Plotter(chatName) {
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
final Graph graph = new Graph(name);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(final Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
|
||||
graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
* ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
public boolean start() {
|
||||
synchronized (optOutLock) {
|
||||
// Did we opt out?
|
||||
if (isOptOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is metrics already running?
|
||||
if (task != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
// Disable Task, if it is running and the server owner decided to opt-out
|
||||
if (isOptOut() && task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
// Tell all plotters to stop gathering information.
|
||||
for (Graph graph : graphs) {
|
||||
graph.onOptOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
postPlugin(!firstPost);
|
||||
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
* @return true if metrics should be opted out of it
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
synchronized (optOutLock) {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(getConfigFile());
|
||||
} catch (IOException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return configuration.getBoolean("opt-out", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (isOptOut()) {
|
||||
configuration.set("opt-out", false);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Enable Task, if it is not running
|
||||
if (task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set it.
|
||||
if (!isOptOut()) {
|
||||
configuration.set("opt-out", true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Disable Task, if it is running
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = plugin.getDataFolder().getParentFile();
|
||||
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
String pluginName = description.getName();
|
||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
String pluginVersion = description.getVersion();
|
||||
String serverVersion = Bukkit.getVersion();
|
||||
int playersOnline = Bukkit.getServer().getOnlinePlayers().size();
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
|
||||
// Construct the post data
|
||||
StringBuilder json = new StringBuilder(1024);
|
||||
json.append('{');
|
||||
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
appendJSONPair(json, "guid", guid);
|
||||
appendJSONPair(json, "plugin_version", pluginVersion);
|
||||
appendJSONPair(json, "server_version", serverVersion);
|
||||
appendJSONPair(json, "players_online", Integer.toString(playersOnline));
|
||||
|
||||
// New data as of R6
|
||||
String osname = System.getProperty("os.name");
|
||||
String osarch = System.getProperty("os.arch");
|
||||
String osversion = System.getProperty("os.version");
|
||||
String java_version = System.getProperty("java.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
// normalize os arch .. amd64 -> x86_64
|
||||
if (osarch.equals("amd64")) {
|
||||
osarch = "x86_64";
|
||||
}
|
||||
|
||||
appendJSONPair(json, "osname", osname);
|
||||
appendJSONPair(json, "osarch", osarch);
|
||||
appendJSONPair(json, "osversion", osversion);
|
||||
appendJSONPair(json, "cores", Integer.toString(coreCount));
|
||||
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
|
||||
appendJSONPair(json, "java_version", java_version);
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
appendJSONPair(json, "ping", "1");
|
||||
}
|
||||
|
||||
if (graphs.size() > 0) {
|
||||
synchronized (graphs) {
|
||||
json.append(',');
|
||||
json.append('"');
|
||||
json.append("graphs");
|
||||
json.append('"');
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
|
||||
boolean firstGraph = true;
|
||||
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
Graph graph = iter.next();
|
||||
|
||||
StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||
}
|
||||
|
||||
graphJson.append('}');
|
||||
|
||||
if (!firstGraph) {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(graph.getName()));
|
||||
json.append(':');
|
||||
json.append(graphJson);
|
||||
|
||||
firstGraph = false;
|
||||
}
|
||||
|
||||
json.append('}');
|
||||
}
|
||||
}
|
||||
|
||||
// close json
|
||||
json.append('}');
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
|
||||
byte[] uncompressed = json.toString().getBytes();
|
||||
byte[] compressed = gzip(json.toString());
|
||||
|
||||
// Headers
|
||||
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
if (debug) {
|
||||
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
|
||||
// Write the data
|
||||
OutputStream os = connection.getOutputStream();
|
||||
os.write(compressed);
|
||||
os.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
os.close();
|
||||
reader.close();
|
||||
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
} else if (response.startsWith("7")) {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
|
||||
throw new IOException(response);
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GZip compress a string of bytes
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public static byte[] gzip(String input) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzos = null;
|
||||
|
||||
try {
|
||||
gzos = new GZIPOutputStream(baos);
|
||||
gzos.write(input.getBytes("UTF-8"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (gzos != null) try {
|
||||
gzos.close();
|
||||
} catch (IOException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a json encoded key/value pair to the given string builder.
|
||||
*
|
||||
* @param json
|
||||
* @param key
|
||||
* @param value
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
|
||||
boolean isValueNumeric;
|
||||
|
||||
try {
|
||||
Double.parseDouble(value);
|
||||
isValueNumeric = true;
|
||||
} catch (NumberFormatException e) {
|
||||
isValueNumeric = false;
|
||||
}
|
||||
|
||||
if (json.charAt(json.length() - 1) != '{') {
|
||||
json.append(',');
|
||||
}
|
||||
|
||||
json.append(escapeJSON(key));
|
||||
json.append(':');
|
||||
|
||||
if (isValueNumeric) {
|
||||
json.append(value);
|
||||
} else {
|
||||
json.append(escapeJSON(value));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a string to create a valid JSON string
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String escapeJSON(String text) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append('"');
|
||||
for (int index = 0; index < text.length(); index++) {
|
||||
char chr = text.charAt(index);
|
||||
|
||||
switch (chr) {
|
||||
case '"':
|
||||
case '\\':
|
||||
builder.append('\\');
|
||||
builder.append(chr);
|
||||
break;
|
||||
case '\b':
|
||||
builder.append("\\b");
|
||||
break;
|
||||
case '\t':
|
||||
builder.append("\\t");
|
||||
break;
|
||||
case '\n':
|
||||
builder.append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.append("\\r");
|
||||
break;
|
||||
default:
|
||||
if (chr < ' ') {
|
||||
String t = "000" + Integer.toHexString(chr);
|
||||
builder.append("\\u" + t.substring(t.length() - 4));
|
||||
} else {
|
||||
builder.append(chr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
builder.append('"');
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text the text to encode
|
||||
* @return the encoded text, as UTF-8
|
||||
*/
|
||||
private static String urlEncode(final String text) throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(final Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(final Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link java.util.Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Graph graph = (Graph) object;
|
||||
return graph.name.equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the server owner decides to opt-out of BukkitMetrics while the server is running.
|
||||
*/
|
||||
protected void onOptOut() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,67 +16,26 @@
|
|||
package net.milkbowl.vault;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_DroxPerms;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_GroupManager;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_OverPermissions;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_Permissions3;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_PermissionsEx;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_Privileges;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_bPermissions;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_bPermissions2;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_iChat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_mChat;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_mChatSuite;
|
||||
import net.milkbowl.vault.chat.plugins.Chat_rscPermissions;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_BOSE7;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_CommandsEX;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_Craftconomy3;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_CurrencyCore;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_DigiCoin;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_Dosh;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_EconXP;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_Essentials;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_GoldIsMoney2;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_GoldenChestEconomy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_Gringotts;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_McMoney;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MineConomy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MultiCurrency;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_TAEcon;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_XPBank;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_eWallet;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_iConomy6;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_SDFEconomy;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_Minefaconomy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_DroxPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_GroupManager;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_OverPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Permissions3;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_PermissionsBukkit;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_PermissionsEx;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Privileges;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_SimplyPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Starburst;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_SuperPerms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_Xperms;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_bPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_bPermissions2;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_TotalPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_rscPermissions;
|
||||
import net.milkbowl.vault.permission.plugins.Permission_KPerms;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -86,7 +45,6 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
@ -97,13 +55,9 @@ import org.json.simple.JSONArray;
|
|||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import com.nijikokun.register.payment.Methods;
|
||||
|
||||
import net.milkbowl.vault.chat.plugins.Chat_TotalPermissions;
|
||||
import net.milkbowl.vault.economy.plugins.Economy_MiConomy;
|
||||
|
||||
public class Vault extends JavaPlugin {
|
||||
|
||||
private static final String VAULT_BUKKIT_URL = "https://dev.bukkit.org/projects/Vault";
|
||||
private static Logger log;
|
||||
private Permission perms;
|
||||
private String newVersionTitle = "";
|
||||
|
@ -111,7 +65,6 @@ public class Vault extends JavaPlugin {
|
|||
private double currentVersion = 0;
|
||||
private String currentVersionTitle = "";
|
||||
private ServicesManager sm;
|
||||
private Metrics metrics;
|
||||
private Vault plugin;
|
||||
|
||||
@Override
|
||||
|
@ -133,7 +86,6 @@ public class Vault extends JavaPlugin {
|
|||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
// Load Vault Addons
|
||||
loadEconomy();
|
||||
loadPermission();
|
||||
loadChat();
|
||||
|
||||
|
@ -166,11 +118,9 @@ public class Vault extends JavaPlugin {
|
|||
newVersion = updateCheck(currentVersion);
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!" + " You are still running version: " + currentVersionTitle);
|
||||
log.warning("Update at: http://dev.bukkit.org/server-mods/vault");
|
||||
log.warning("Update at: https://dev.bukkit.org/projects/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle + " | Current Version: " + currentVersionTitle);
|
||||
} else {
|
||||
log.info("No new version available");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore exceptions
|
||||
|
@ -180,17 +130,12 @@ public class Vault extends JavaPlugin {
|
|||
}, 0, 432000);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Load up the Plugin metrics
|
||||
try {
|
||||
metrics = new Metrics(this);
|
||||
metrics.findCustomData();
|
||||
metrics.start();
|
||||
} catch (IOException e) {
|
||||
// ignore exception
|
||||
}
|
||||
Metrics metrics = new Metrics(this, 887);
|
||||
findCustomData(metrics);
|
||||
|
||||
log.info(String.format("Enabled Version %s", getDescription().getVersion()));
|
||||
}
|
||||
|
||||
|
@ -201,160 +146,26 @@ public class Vault extends JavaPlugin {
|
|||
// Try to load PermissionsEx
|
||||
hookChat("PermissionsEx", Chat_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
|
||||
|
||||
// Try to load mChatSuite
|
||||
hookChat("mChatSuite", Chat_mChatSuite.class, ServicePriority.Highest, "in.mDev.MiracleM4n.mChatSuite.mChatSuite");
|
||||
|
||||
// Try to load mChat
|
||||
hookChat("mChat", Chat_mChat.class, ServicePriority.Highest, "net.D3GN.MiracleM4n.mChat");
|
||||
|
||||
// Try to load OverPermissions
|
||||
hookChat("OverPermissions", Chat_OverPermissions.class, ServicePriority.Highest, "com.overmc.overpermissions.internal.OverPermissions");
|
||||
|
||||
// Try to load DroxPerms Chat
|
||||
hookChat("DroxPerms", Chat_DroxPerms.class, ServicePriority.Lowest, "de.hydrox.bukkit.DroxPerms.DroxPerms");
|
||||
|
||||
// Try to load bPermssions 2
|
||||
hookChat("bPermssions2", Chat_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.ApiLayer");
|
||||
|
||||
// Try to load bPermissions 1
|
||||
hookChat("bPermissions", Chat_bPermissions.class, ServicePriority.Normal, "de.bananaco.permissions.info.InfoReader");
|
||||
|
||||
// Try to load GroupManager
|
||||
hookChat("GroupManager", Chat_GroupManager.class, ServicePriority.Normal, "org.anjocaido.groupmanager.GroupManager");
|
||||
|
||||
// Try to load Permissions 3 (Yeti)
|
||||
hookChat("Permissions3", Chat_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
|
||||
|
||||
// Try to load iChat
|
||||
hookChat("iChat", Chat_iChat.class, ServicePriority.Low, "net.TheDgtl.iChat.iChat");
|
||||
|
||||
// Try to load Privileges
|
||||
hookChat("Privileges", Chat_Privileges.class, ServicePriority.Normal, "net.krinsoft.privileges.Privileges");
|
||||
|
||||
// Try to load rscPermissions
|
||||
hookChat("rscPermissions", Chat_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
|
||||
|
||||
//Try to load TotalPermissions
|
||||
hookChat("TotalPermissions", Chat_TotalPermissions.class, ServicePriority.Normal, "net.ar97.totalpermissions.TotalPermissions");
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load Economy Addons
|
||||
*/
|
||||
private void loadEconomy() {
|
||||
// Try to load MiConomy
|
||||
hookEconomy("MiConomy", Economy_MiConomy.class, ServicePriority.Normal, "com.gmail.bleedobsidian.miconomy.Main");
|
||||
|
||||
// Try to load MiFaConomy
|
||||
hookEconomy("MineFaConomy", Economy_Minefaconomy.class, ServicePriority.Normal, "me.coniin.plugins.minefaconomy.Minefaconomy");
|
||||
|
||||
// Try to load MultiCurrency
|
||||
hookEconomy("MultiCurrency", Economy_MultiCurrency.class, ServicePriority.Normal, "me.ashtheking.currency.Currency", "me.ashtheking.currency.CurrencyList");
|
||||
|
||||
// Try to load MineConomy
|
||||
hookEconomy("MineConomy", Economy_MineConomy.class, ServicePriority.Normal, "me.mjolnir.mineconomy.MineConomy");
|
||||
|
||||
// Try to load McMoney
|
||||
hookEconomy("McMoney", Economy_McMoney.class, ServicePriority.Normal, "boardinggamer.mcmoney.McMoneyAPI");
|
||||
|
||||
// Try to load Craftconomy3
|
||||
hookEconomy("CraftConomy3", Economy_Craftconomy3.class, ServicePriority.Normal, "com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader");
|
||||
|
||||
// Try to load eWallet
|
||||
hookEconomy("eWallet", Economy_eWallet.class, ServicePriority.Normal, "me.ethan.eWallet.ECO");
|
||||
|
||||
// Try to load BOSEconomy 7
|
||||
hookEconomy("BOSEconomy7", Economy_BOSE7.class, ServicePriority.Normal, "cosine.boseconomy.BOSEconomy", "cosine.boseconomy.CommandHandler");
|
||||
|
||||
// Try to load CurrencyCore
|
||||
hookEconomy("CurrencyCore", Economy_CurrencyCore.class, ServicePriority.Normal, "is.currency.Currency");
|
||||
|
||||
// Try to load Gringotts
|
||||
hookEconomy("Gringotts", Economy_Gringotts.class, ServicePriority.Normal, "org.gestern.gringotts.Gringotts");
|
||||
|
||||
// Try to load Essentials Economy
|
||||
hookEconomy("Essentials Economy", Economy_Essentials.class, ServicePriority.Low, "com.earth2me.essentials.api.Economy", "com.earth2me.essentials.api.NoLoanPermittedException", "com.earth2me.essentials.api.UserDoesNotExistException");
|
||||
|
||||
// Try to load iConomy 6
|
||||
hookEconomy("iConomy 6", Economy_iConomy6.class, ServicePriority.High, "com.iCo6.iConomy");
|
||||
|
||||
// Try to load EconXP
|
||||
hookEconomy("EconXP", Economy_EconXP.class, ServicePriority.Normal, "ca.agnate.EconXP.EconXP");
|
||||
|
||||
// Try to load GoldIsMoney2
|
||||
hookEconomy("GoldIsMoney2", Economy_GoldIsMoney2.class, ServicePriority.Normal, "com.flobi.GoldIsMoney2.GoldIsMoney");
|
||||
|
||||
// Try to load GoldenChestEconomy
|
||||
hookEconomy("GoldenChestEconomy", Economy_GoldenChestEconomy.class, ServicePriority.Normal, "me.igwb.GoldenChest.GoldenChestEconomy");
|
||||
|
||||
// Try to load Dosh
|
||||
hookEconomy("Dosh", Economy_Dosh.class, ServicePriority.Normal, "com.gravypod.Dosh.Dosh");
|
||||
|
||||
// Try to load CommandsEX Economy
|
||||
hookEconomy("CommandsEX", Economy_CommandsEX.class, ServicePriority.Normal, "com.github.zathrus_writer.commandsex.api.EconomyAPI");
|
||||
|
||||
// Try to load SDFEconomy Economy
|
||||
hookEconomy("SDFEconomy", Economy_SDFEconomy.class, ServicePriority.Normal, "com.github.omwah.SDFEconomy.SDFEconomy");
|
||||
|
||||
// Try to load XPBank
|
||||
hookEconomy("XPBank", Economy_XPBank.class, ServicePriority.Normal, "com.gmail.mirelatrue.xpbank.XPBank");
|
||||
|
||||
// Try to load TAEcon
|
||||
hookEconomy("TAEcon", Economy_TAEcon.class, ServicePriority.Normal, "net.teamalpha.taecon.TAEcon");
|
||||
|
||||
// Try to load DigiCoin
|
||||
hookEconomy("DigiCoin", Economy_DigiCoin.class, ServicePriority.Normal, "co.uk.silvania.cities.digicoin.DigiCoin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to load Permission Addons
|
||||
*/
|
||||
private void loadPermission() {
|
||||
// Try to load Starburst
|
||||
hookPermission("Starburst", Permission_Starburst.class, ServicePriority.Highest, "com.dthielke.starburst.StarburstPlugin");
|
||||
|
||||
// Try to load PermissionsEx
|
||||
hookPermission("PermissionsEx", Permission_PermissionsEx.class, ServicePriority.Highest, "ru.tehkode.permissions.bukkit.PermissionsEx");
|
||||
|
||||
// Try to load OverPermissions
|
||||
hookPermission("OverPermissions", Permission_OverPermissions.class, ServicePriority.Highest, "com.overmc.overpermissions.internal.OverPermissions");
|
||||
|
||||
// Try to load PermissionsBukkit
|
||||
hookPermission("PermissionsBukkit", Permission_PermissionsBukkit.class, ServicePriority.Normal, "com.platymuus.bukkit.permissions.PermissionsPlugin");
|
||||
|
||||
// Try to load DroxPerms
|
||||
hookPermission("DroxPerms", Permission_DroxPerms.class, ServicePriority.High, "de.hydrox.bukkit.DroxPerms.DroxPerms");
|
||||
|
||||
// Try to load SimplyPerms
|
||||
hookPermission("SimplyPerms", Permission_SimplyPerms.class, ServicePriority.Highest, "net.crystalyx.bukkit.simplyperms.SimplyPlugin");
|
||||
|
||||
// Try to load bPermissions2
|
||||
hookPermission("bPermissions 2", Permission_bPermissions2.class, ServicePriority.Highest, "de.bananaco.bpermissions.api.WorldManager");
|
||||
|
||||
// Try to load Privileges
|
||||
hookPermission("Privileges", Permission_Privileges.class, ServicePriority.Highest, "net.krinsoft.privileges.Privileges");
|
||||
|
||||
// Try to load bPermissions
|
||||
hookPermission("bPermissions", Permission_bPermissions.class, ServicePriority.High, "de.bananaco.permissions.SuperPermissionHandler");
|
||||
|
||||
// Try to load GroupManager
|
||||
hookPermission("GroupManager", Permission_GroupManager.class, ServicePriority.High, "org.anjocaido.groupmanager.GroupManager");
|
||||
|
||||
// Try to load Permissions 3 (Yeti)
|
||||
hookPermission("Permissions 3 (Yeti)", Permission_Permissions3.class, ServicePriority.Normal, "com.nijiko.permissions.ModularControl");
|
||||
|
||||
// Try to load Xperms
|
||||
hookPermission("Xperms", Permission_Xperms.class, ServicePriority.Low, "com.github.sebc722.Xperms");
|
||||
|
||||
//Try to load TotalPermissions
|
||||
hookPermission("TotalPermissions", Permission_TotalPermissions.class, ServicePriority.Normal, "net.ae97.totalpermissions.TotalPermissions");
|
||||
|
||||
// Try to load rscPermissions
|
||||
hookPermission("rscPermissions", Permission_rscPermissions.class, ServicePriority.Normal, "ru.simsonic.rscPermissions.MainPluginClass");
|
||||
|
||||
// Try to load KPerms
|
||||
hookPermission("KPerms", Permission_KPerms.class, ServicePriority.Normal, "com.lightniinja.kperms.KPermsPlugin");
|
||||
|
||||
Permission perms = new Permission_SuperPerms(this);
|
||||
sm.register(Permission.class, perms, this, ServicePriority.Lowest);
|
||||
log.info(String.format("[Permission] SuperPermissions loaded as backup permission system."));
|
||||
|
@ -374,18 +185,6 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private void hookEconomy (String name, Class<? extends Economy> hookClass, ServicePriority priority, String...packages) {
|
||||
try {
|
||||
if (packagesExists(packages)) {
|
||||
Economy econ = hookClass.getConstructor(Plugin.class).newInstance(this);
|
||||
sm.register(Economy.class, econ, this, priority);
|
||||
log.info(String.format("[Economy] %s found: %s", name, econ.isEnabled() ? "Loaded" : "Waiting"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(String.format("[Economy] There was an error hooking %s - check to make sure you're using a compatible version!", name));
|
||||
}
|
||||
}
|
||||
|
||||
private void hookPermission (String name, Class<? extends Permission> hookClass, ServicePriority priority, String...packages) {
|
||||
try {
|
||||
if (packagesExists(packages)) {
|
||||
|
@ -576,6 +375,45 @@ public class Vault extends JavaPlugin {
|
|||
return currentVersion;
|
||||
}
|
||||
|
||||
private void findCustomData(Metrics metrics) {
|
||||
// Create our Economy Graph and Add our Economy plotters
|
||||
RegisteredServiceProvider<Economy> rspEcon = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
Economy econ = null;
|
||||
if (rspEcon != null) {
|
||||
econ = rspEcon.getProvider();
|
||||
}
|
||||
final String econName = econ != null ? econ.getName() : "No Economy";
|
||||
metrics.addCustomChart(new SimplePie("economy", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return econName;
|
||||
}
|
||||
}));
|
||||
|
||||
// Create our Permission Graph and Add our permission Plotters
|
||||
final String permName = Bukkit.getServer().getServicesManager().getRegistration(Permission.class).getProvider().getName();
|
||||
metrics.addCustomChart(new SimplePie("permission", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return permName;
|
||||
}
|
||||
}));
|
||||
|
||||
// Create our Chat Graph and Add our chat Plotters
|
||||
RegisteredServiceProvider<Chat> rspChat = Bukkit.getServer().getServicesManager().getRegistration(Chat.class);
|
||||
Chat chat = null;
|
||||
if (rspChat != null) {
|
||||
chat = rspChat.getProvider();
|
||||
}
|
||||
final String chatName = chat != null ? chat.getName() : "No Chat";
|
||||
metrics.addCustomChart(new SimplePie("chat", new Callable<String>() {
|
||||
@Override
|
||||
public String call() {
|
||||
return chatName;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public class VaultListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
@ -585,7 +423,7 @@ public class Vault extends JavaPlugin {
|
|||
try {
|
||||
if (newVersion > currentVersion) {
|
||||
player.sendMessage("Vault " + newVersionTitle + " is out! You are running " + currentVersionTitle);
|
||||
player.sendMessage("Update Vault at: http://dev.bukkit.org/server-mods/vault");
|
||||
player.sendMessage("Update Vault at: " + VAULT_BUKKIT_URL);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Ignore exceptions
|
||||
|
@ -593,32 +431,5 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Register") && packagesExists("com.nijikokun.register.payment.Methods")) {
|
||||
if (!Methods.hasMethod()) {
|
||||
try {
|
||||
Method m = Methods.class.getMethod("addMethod", Methods.class);
|
||||
m.setAccessible(true);
|
||||
m.invoke(null, "Vault", new net.milkbowl.vault.VaultEco());
|
||||
if (!Methods.setPreferred("Vault")) {
|
||||
log.info("Unable to hook register");
|
||||
} else {
|
||||
log.info("[Vault] - Successfully injected Vault methods into Register.");
|
||||
}
|
||||
} catch (SecurityException e) {
|
||||
log.info("Unable to hook register");
|
||||
} catch (NoSuchMethodException e) {
|
||||
log.info("Unable to hook register");
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.info("Unable to hook register");
|
||||
} catch (IllegalAccessException e) {
|
||||
log.info("Unable to hook register");
|
||||
} catch (InvocationTargetException e) {
|
||||
log.info("Unable to hook register");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,243 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import com.nijikokun.register.payment.Method;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class VaultEco implements Method {
|
||||
|
||||
private Vault vault;
|
||||
private Economy economy;
|
||||
|
||||
public Vault getPlugin() {
|
||||
return this.vault;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean createAccount(String name, Double amount) {
|
||||
if(!this.economy.createBank(name, "").transactionSuccess()) {
|
||||
return false;
|
||||
}
|
||||
return this.economy.bankDeposit(name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.vault.getDescription().getName();
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.vault.getDescription().getVersion();
|
||||
}
|
||||
|
||||
public int fractionalDigits() {
|
||||
return this.economy.fractionalDigits();
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.economy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return this.economy.hasBankSupport();
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.economy.getBanks().contains(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.economy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.economy.isBankOwner(bank, name).transactionSuccess() || this.economy.isBankMember(bank, name).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean createAccount(String name) {
|
||||
return this.economy.createPlayerAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new VaultAccount(name, this.economy);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new VaultBankAccount(bank, economy);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin instanceof Vault;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
this.vault = (Vault) plugin;
|
||||
RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (economyProvider != null) {
|
||||
this.economy = economyProvider.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
public class VaultAccount implements MethodAccount {
|
||||
private final String name;
|
||||
private final Economy economy;
|
||||
|
||||
public VaultAccount(String name, Economy economy) {
|
||||
this.name = name;
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.economy.getBalance(this.name);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(!this.economy.withdrawPlayer(this.name, this.balance()).transactionSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(amount == 0) {
|
||||
return true;
|
||||
}
|
||||
return this.economy.depositPlayer(this.name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.economy.depositPlayer(this.name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
return this.economy.withdrawPlayer(this.name, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.set(balance * amount);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.set(balance / amount);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.set(0.0);
|
||||
}
|
||||
}
|
||||
|
||||
public class VaultBankAccount implements MethodBankAccount {
|
||||
|
||||
private final String bank;
|
||||
private final Economy economy;
|
||||
|
||||
public VaultBankAccount(String bank, Economy economy) {
|
||||
this.bank = bank;
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.economy.bankBalance(this.bank).balance;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(!this.economy.bankWithdraw(this.bank, this.balance()).transactionSuccess()) {
|
||||
return false;
|
||||
}
|
||||
if(amount == 0) {
|
||||
return true;
|
||||
}
|
||||
return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
return this.economy.bankWithdraw(this.bank, amount).transactionSuccess();
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.set(balance * amount);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.set(balance / amount);
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.set(0.0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,238 +0,0 @@
|
|||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
public class Chat_DroxPerms extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "DroxPerms";
|
||||
private Plugin plugin;
|
||||
private DroxPermsAPI API;
|
||||
|
||||
public Chat_DroxPerms(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (API == null) {
|
||||
DroxPerms p = (DroxPerms) plugin.getServer().getPluginManager().getPlugin("DroxPerms");
|
||||
if (p != null) {
|
||||
API = p.getAPI();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (API == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals("DroxPerms")) {
|
||||
API = ((DroxPerms) permPlugin).getAPI();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
String prefix = API.getPlayerInfo(player, "prefix");
|
||||
if (prefix == null) {
|
||||
String prigroup = API.getPlayerGroup(player);
|
||||
prefix = API.getGroupInfo(prigroup, "prefix");
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
API.setPlayerInfo(player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return API.getPlayerInfo(player, "suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
API.setPlayerInfo(player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return API.getGroupInfo(group, "prefix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
API.setGroupInfo(group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return API.getGroupInfo(group, "suffix");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
API.setGroupInfo(group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
API.setPlayerInfo(player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
API.setGroupInfo(group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
API.setPlayerInfo(player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
API.setGroupInfo(group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
API.setPlayerInfo(player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
API.setGroupInfo(group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = API.getPlayerInfo(player, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
API.setPlayerInfo(player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = API.getGroupInfo(group, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
API.setGroupInfo(group, node, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class Chat_GroupManager extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Logger log;
|
||||
private final String name = "GroupManager - Chat";
|
||||
private Plugin plugin = null;
|
||||
private GroupManager groupManager;
|
||||
|
@ -43,6 +43,7 @@ public class Chat_GroupManager extends Chat {
|
|||
public Chat_GroupManager(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
|
|
|
@ -1,317 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.overmc.overpermissions.api.GroupManager;
|
||||
import com.overmc.overpermissions.api.PermissionGroup;
|
||||
import com.overmc.overpermissions.api.PermissionUser;
|
||||
import com.overmc.overpermissions.api.UserManager;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Chat_OverPermissions extends Chat {
|
||||
protected final Plugin plugin;
|
||||
private OverPermissions overPerms;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Chat_OverPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (overPerms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (p != null) {
|
||||
overPerms = (OverPermissions) p;
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName( ) {
|
||||
return "OverPermissions_Chat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled( ) {
|
||||
return overPerms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return getPlayerInfoString(world, player, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoString(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return getPlayerInfoString(world, player, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoString(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return getGroupInfoString(world, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoString(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return getGroupInfoString(world, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfoString(world, group, "prefix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Integer.valueOf(s).intValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Double.valueOf(s).doubleValue();
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val.booleanValue() : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
setPlayerInfoString(world, player, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val.booleanValue() : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
setGroupInfoString(world, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return defaultValue;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
if (world == null) { // Retrieve meta from the global store.
|
||||
if (!user.hasGlobalMeta(node)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return user.getGlobalMeta(node);
|
||||
} else {
|
||||
if (!user.hasMeta(node, world)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return user.getMeta(node, world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String playerName, String node, String value) {
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
if (world != null) {
|
||||
if (value == null) {
|
||||
user.removeMeta(node, world);
|
||||
} else {
|
||||
user.setMeta(node, value, world);
|
||||
}
|
||||
} else {
|
||||
if (value == null) {
|
||||
user.removeGlobalMeta(node);
|
||||
} else {
|
||||
user.setGlobalMeta(node, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return defaultValue;
|
||||
}
|
||||
PermissionGroup group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (world == null) { // Retrieve from the global store.
|
||||
if (!group.hasGlobalMeta(node)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return group.getGlobalMeta(node);
|
||||
} else {
|
||||
if (!group.hasMeta(node, world)) {
|
||||
return defaultValue;
|
||||
}
|
||||
return group.getMeta(node, world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
if (!overPerms.getGroupManager().doesGroupExist(groupName)) {
|
||||
return;
|
||||
}
|
||||
PermissionGroup group = overPerms.getGroupManager().getGroup(groupName);
|
||||
if (world != null) {
|
||||
if (value == null) {
|
||||
group.removeMeta(node, world);
|
||||
} else {
|
||||
group.setMeta(node, value, world);
|
||||
}
|
||||
} else {
|
||||
if (value == null) {
|
||||
group.removeGlobalMeta(node);
|
||||
} else {
|
||||
group.setGlobalMeta(node, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_OverPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_OverPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.overPerms == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (chat != null) {
|
||||
this.chat.overPerms = (OverPermissions) chat;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", new Object[] {plugin.getDescription().getName(), getName()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if ((chat.overPerms != null) &&
|
||||
(event.getPlugin().getDescription().getName().equals("OverPermissions"))) {
|
||||
chat.overPerms = null;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s un-hooked.", new Object[] {plugin.getDescription().getName(), getName()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,240 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Chat_Permissions3 extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private String name = "Permissions 3 (Yeti) - Chat";
|
||||
private PermissionHandler perms;
|
||||
private Plugin plugin = null;
|
||||
private Permissions chat = null;
|
||||
|
||||
public Chat_Permissions3(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (chat == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (p == null) {
|
||||
plugin.getServer().getPluginManager().getPlugin("vPerms");
|
||||
name = "vPerms - Chat";
|
||||
}
|
||||
if (p != null) {
|
||||
if (p.isEnabled() && p.getDescription().getVersion().startsWith("3")) {
|
||||
chat = (Permissions) p;
|
||||
this.perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat == null) {
|
||||
Plugin permChat = event.getPlugin();
|
||||
if((permChat.getDescription().getName().equals("Permissions") || permChat.getDescription().getName().equals("vPerms")) && permChat.getDescription().getVersion().startsWith("3")) {
|
||||
if (permChat.isEnabled()) {
|
||||
chat = (Permissions) permChat;
|
||||
perms = chat.getHandler();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions") || event.getPlugin().getDescription().getName().equals("vPerms")) {
|
||||
chat = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (chat == null) {
|
||||
return false;
|
||||
} else {
|
||||
return chat.isEnabled();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
|
||||
Integer i = this.perms.getPermissionInteger(world, playerName, node);
|
||||
return (i == null) ? defaultValue : i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
|
||||
Double d = this.perms.getPermissionDouble(world, playerName, node);
|
||||
return (d == null) ? defaultValue : d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
|
||||
Boolean b = this.perms.getPermissionBoolean(world, playerName, node);
|
||||
return (b == null) ? defaultValue : b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
|
||||
String s = this.perms.getPermissionString(world, playerName, node);
|
||||
return (s == null) ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String playerName) {
|
||||
return getPlayerInfoString(world, playerName, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
//this.perms.addUserInfo(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
public void setPlayerInfo(String world, String playerName, String node, Object value) {
|
||||
//this.perms.addUserInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String playerName, String node, String value) {
|
||||
setPlayerInfo(world, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue) {
|
||||
int i = this.perms.getGroupPermissionInteger(world, groupName, node);
|
||||
return i != -1 ? i : defaultValue;
|
||||
}
|
||||
|
||||
|
||||
public void setGroupInfo(String world, String groupName, String node, Object value) {
|
||||
this.perms.addGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
|
||||
setGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue) {
|
||||
double d = this.perms.getGroupPermissionDouble(world, groupName, node);
|
||||
return d != -1.0d ? d : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
|
||||
setGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue) {
|
||||
return this.perms.getGroupPermissionBoolean(world, groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
|
||||
setGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String groupName, String node, String defaultValue) {
|
||||
String s = this.perms.getGroupPermissionString(world, groupName, node);
|
||||
return s != null ? s : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
setGroupInfo(world, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return this.perms.getGroupPrefix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
this.perms.addGroupInfo(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return this.perms.getGroupSuffix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
this.perms.addGroupInfo(world, group, "suffix", suffix);
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ import ru.tehkode.permissions.PermissionUser;
|
|||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
|
||||
public class Chat_PermissionsEx extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Logger log;
|
||||
private final String name = "PermissionsEx_Chat";
|
||||
|
||||
private Plugin plugin = null;
|
||||
|
@ -43,6 +43,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
public Chat_PermissionsEx(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
|
|
@ -1,231 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import net.krinsoft.privileges.Privileges;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_Privileges extends Chat {
|
||||
private static final String FRIENDLY_NAME = "Privileges - Chat";
|
||||
private static final String PLUGIN_NAME = "Privileges";
|
||||
private static final String CHAT_PREFIX_KEY = "prefix";
|
||||
private static final String CHAT_SUFFIX_KEY = "suffix";
|
||||
|
||||
private Privileges privs;
|
||||
private final Plugin plugin;
|
||||
|
||||
public Chat_Privileges(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (privs == null) {
|
||||
Plugin privsPlugin = plugin.getServer().getPluginManager().getPlugin(PLUGIN_NAME);
|
||||
if (privsPlugin != null && privsPlugin.isEnabled()) {
|
||||
this.privs = (Privileges) privsPlugin;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return FRIENDLY_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return privs != null && privs.isEnabled();
|
||||
}
|
||||
|
||||
private String getPlayerOrGroupInfoString(String world, String player, String key, String defaultValue) {
|
||||
String value = getPlayerInfoString(world, player, key, null);
|
||||
if (value != null) return value;
|
||||
|
||||
value = getGroupInfoString(world, getPrimaryGroup(world, player), key, null);
|
||||
if (value != null) return value;
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private void worldCheck(String world) {
|
||||
if (world != null && !world.isEmpty()) {
|
||||
throw new UnsupportedOperationException("Privileges does not support multiple worlds for player/group metadata.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return getPlayerOrGroupInfoString(world, player, CHAT_PREFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoString(world, player, CHAT_PREFIX_KEY, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return getPlayerOrGroupInfoString(world, player, CHAT_SUFFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoString(world, player, CHAT_SUFFIX_KEY, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return getGroupInfoString(world, group, CHAT_PREFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoString(world, group, CHAT_PREFIX_KEY, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return getGroupInfoString(world, group, CHAT_SUFFIX_KEY, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfoString(world, group, CHAT_SUFFIX_KEY, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
return privs.getUserNode(player).getInt(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
return privs.getGroupNode(group).getInt(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
return privs.getUserNode(player).getDouble(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
return privs.getGroupNode(group).getDouble(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
return privs.getUserNode(player).getBoolean(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
return privs.getGroupNode(group).getBoolean(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
return privs.getUserNode(player).getString(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
worldCheck(world);
|
||||
privs.getUserNode(player).set(node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
return privs.getGroupNode(group).getString(node, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
worldCheck(world);
|
||||
privs.getGroupNode(group).set(node, value);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (privs == null) {
|
||||
Plugin permChat = event.getPlugin();
|
||||
if (PLUGIN_NAME.equals(permChat.getDescription().getName())) {
|
||||
if (permChat.isEnabled()) {
|
||||
privs = (Privileges) permChat;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (privs != null) {
|
||||
if (PLUGIN_NAME.equals(event.getPlugin().getDescription().getName())) {
|
||||
privs = null;
|
||||
plugin.getLogger().info(String.format("[Chat] %s un-hooked.", FRIENDLY_NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,287 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import net.ae97.totalpermissions.PermissionManager;
|
||||
import net.ae97.totalpermissions.TotalPermissions;
|
||||
import net.ae97.totalpermissions.permission.PermissionBase;
|
||||
import net.ae97.totalpermissions.permission.PermissionGroup;
|
||||
import net.ae97.totalpermissions.permission.PermissionUser;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @author Lord_Ralex
|
||||
*/
|
||||
public class Chat_TotalPermissions extends Chat {
|
||||
|
||||
private final Plugin plugin;
|
||||
private TotalPermissions totalPermissions;
|
||||
private final String name = "TotalPermissions-Chat";
|
||||
|
||||
public Chat_TotalPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (totalPermissions == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("TotalPermissions");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
totalPermissions = (TotalPermissions) chat;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_TotalPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_TotalPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.totalPermissions == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms != null) {
|
||||
if (perms.getDescription().getName().equals("TotalPermissions")) {
|
||||
if (perms.isEnabled()) {
|
||||
chat.totalPermissions = (TotalPermissions) perms;
|
||||
plugin.getLogger().info(String.format("[Chat] %s hooked.", chat.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.totalPermissions != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("TotalPermissions")) {
|
||||
chat.totalPermissions = null;
|
||||
plugin.getLogger().info(String.format("[Chat] %s un-hooked.", chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return (totalPermissions == null ? false : totalPermissions.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return this.getPlayerInfoString(world, player, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
this.setPlayerInfoString(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return this.getPlayerInfoString(world, player, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
this.setPlayerInfoString(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return this.getGroupInfoString(world, group, "prefix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
this.setGroupInfoString(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return this.getGroupInfoString(world, group, "suffix", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
this.setGroupInfoString(world, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Integer) {
|
||||
return (Integer) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Integer) {
|
||||
return (Integer) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Double) {
|
||||
return (Double) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Double) {
|
||||
return (Double) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof Boolean) {
|
||||
return (Boolean) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof Boolean) {
|
||||
return (Boolean) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Object pre = getPlayerInfo(world, player, node);
|
||||
if (pre instanceof String) {
|
||||
return (String) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
setPlayerInfo(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
Object pre = getGroupInfo(world, group, node);
|
||||
if (pre instanceof String) {
|
||||
return (String) pre;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
setGroupInfo(world, group, node, value);
|
||||
}
|
||||
|
||||
private PermissionUser getUser(String name) {
|
||||
PermissionManager manager = totalPermissions.getManager();
|
||||
PermissionUser user = manager.getUser(name);
|
||||
return user;
|
||||
}
|
||||
|
||||
private PermissionGroup getGroup(String name) {
|
||||
PermissionManager manager = totalPermissions.getManager();
|
||||
PermissionGroup group = manager.getGroup(name);
|
||||
return group;
|
||||
}
|
||||
|
||||
private void setPlayerInfo(String world, String player, String node, Object value) {
|
||||
PermissionBase base = getUser(player);
|
||||
base.setOption(node, value, world);
|
||||
}
|
||||
|
||||
private void setGroupInfo(String world, String group, String node, Object value) {
|
||||
PermissionBase base = getGroup(group);
|
||||
base.setOption(node, value, world);
|
||||
}
|
||||
|
||||
private Object getPlayerInfo(String world, String player, String node) {
|
||||
PermissionBase base = getUser(player);
|
||||
return base.getOption(node);
|
||||
}
|
||||
|
||||
private Object getGroupInfo(String world, String group, String node) {
|
||||
PermissionBase base = getUser(group);
|
||||
return base.getOption(node);
|
||||
}
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.info.InfoReader;
|
||||
|
||||
public class Chat_bPermissions extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "bInfo";
|
||||
private Plugin plugin = null;
|
||||
InfoReader chat;
|
||||
|
||||
public Chat_bPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (chat == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
chat = Permissions.getInfoReader();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_bPermissions chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_bPermissions chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.chat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("bPermissions")) {
|
||||
this.chat.chat = Permissions.getInfoReader();
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.chat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
this.chat.chat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "bPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return chat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return chat.getPrefix(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return chat.getSuffix(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return chat.getGroupPrefix(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return chat.getGroupSuffix(group, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String s = getGroupInfoString(world, group, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = chat.getValue(player, world, node);
|
||||
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = chat.getGroupValue(group, world, node);
|
||||
return (val == null || val == "BLANKWORLD") ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("bPermissions does not support altering info nodes");
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import de.bananaco.bpermissions.api.ApiLayer;
|
|||
import de.bananaco.bpermissions.api.CalculableType;
|
||||
|
||||
public class Chat_bPermissions2 extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Logger log;
|
||||
private final String name = "bInfo";
|
||||
private Plugin plugin = null;
|
||||
private boolean hooked = false;
|
||||
|
@ -40,6 +40,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
public Chat_bPermissions2(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
|
|
@ -1,273 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.TheDgtl.iChat.iChat;
|
||||
import net.TheDgtl.iChat.iChatAPI;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_iChat extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "iChat";
|
||||
private Plugin plugin = null;
|
||||
private iChatAPI iChat = null;
|
||||
|
||||
public Chat_iChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (iChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("iChat");
|
||||
if (chat != null) {
|
||||
iChat = ((iChat) chat).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_iChat chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_iChat chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.iChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("iChat")) {
|
||||
this.chat.iChat = ((iChat) chat).API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.iChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("iChat")) {
|
||||
this.chat.iChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "iChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return iChat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return iChat.getPrefix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return iChat.getSuffix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Integer i = defaultValue;
|
||||
try {
|
||||
i = Integer.valueOf(val);
|
||||
return i;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
double d = defaultValue;
|
||||
try {
|
||||
d = Double.valueOf(val);
|
||||
return d;
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String val = getPlayerInfoString(world, player, node, null);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean v = Boolean.valueOf(val);
|
||||
return v != null ? v : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("iChat does not support offline player info nodes!");
|
||||
}
|
||||
|
||||
if (!p.getWorld().getName().equals(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String val = iChat.getInfo(p, node);
|
||||
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("iChat does not support group info nodes!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("iChat does not support mutable info nodes!");
|
||||
}
|
||||
}
|
|
@ -1,250 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.D3GN.MiracleM4n.mChat.mChatAPI;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_mChat extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "mChat";
|
||||
private Plugin plugin = null;
|
||||
private mChatAPI mChat = null;
|
||||
|
||||
public Chat_mChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChat");
|
||||
if (chat != null) {
|
||||
mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_mChat chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_mChat chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (this.chat.mChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("mChat")) {
|
||||
this.chat.mChat = net.D3GN.MiracleM4n.mChat.mChat.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.chat.mChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("mChat")) {
|
||||
this.chat.mChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mChat != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
return mChat.getPrefix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
return mChat.getSuffix(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.valueOf(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String s = getPlayerInfoString(world, player, node, null);
|
||||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
Player p = Bukkit.getServer().getPlayer(player);
|
||||
if (p ==null) {
|
||||
throw new UnsupportedOperationException("mChat does not support offline player prefixes");
|
||||
}
|
||||
String s = mChat.getInfo(p, node);
|
||||
return s == null ? defaultValue : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throw new UnsupportedOperationException("mChat does not support setting info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throw new UnsupportedOperationException("mChat does not support group info nodes");
|
||||
}
|
||||
}
|
|
@ -1,284 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import com.miraclem4n.mchat.api.Reader;
|
||||
import com.miraclem4n.mchat.api.Writer;
|
||||
import com.miraclem4n.mchat.types.InfoType;
|
||||
import in.mDev.MiracleM4n.mChatSuite.mChatSuite;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Chat_mChatSuite extends Chat {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "mChatSuite";
|
||||
private Plugin plugin = null;
|
||||
private mChatSuite mChat = null;
|
||||
|
||||
public Chat_mChatSuite(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (mChat == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("mChatSuite");
|
||||
if (chat != null && chat.isEnabled()) {
|
||||
mChat = (mChatSuite) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (mChat == null) {
|
||||
Plugin chat = event.getPlugin();
|
||||
if (chat.getDescription().getName().equals("mChatSuite")) {
|
||||
mChat = (mChatSuite) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (mChat != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("mChatSuite")) {
|
||||
mChat = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), "mChatSuite"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return mChat != null && mChat.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return Reader.getPrefix(player, InfoType.USER, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
setPlayerInfoValue(world, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return Reader.getSuffix(player, InfoType.USER, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
setPlayerInfoValue(world, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return Reader.getPrefix(group, InfoType.GROUP, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
setGroupInfoValue(world, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return Reader.getSuffix(group, InfoType.GROUP, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
setGroupInfoValue(world, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node,double defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.parseBoolean(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null || val.equals("")) {
|
||||
return defaultValue;
|
||||
}
|
||||
return Boolean.valueOf(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = getPlayerInfoValue(world, player, node);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
setPlayerInfoValue(world, player, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = getGroupInfoValue(world, group, node);
|
||||
if (val == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
setGroupInfoValue(world, group, node, value);
|
||||
}
|
||||
|
||||
private void setPlayerInfoValue(String world, String player, String node, Object value) {
|
||||
if (world != null) {
|
||||
Writer.setWorldVar(player, InfoType.USER, world, node, value.toString());
|
||||
} else {
|
||||
Writer.setInfoVar(player, InfoType.USER, node, value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void setGroupInfoValue(String world, String group, String node, Object value) {
|
||||
if (world != null) {
|
||||
Writer.setWorldVar(group, InfoType.GROUP, world, node, value);
|
||||
} else {
|
||||
Writer.setInfoVar(group, InfoType.GROUP, node, value);
|
||||
}
|
||||
}
|
||||
private String getPlayerInfoValue(String world, String player, String node) {
|
||||
return Reader.getInfo(player, InfoType.USER, world, node);
|
||||
}
|
||||
|
||||
private String getGroupInfoValue(String world, String group, String node) {
|
||||
return Reader.getInfo(group, InfoType.GROUP, world, node);
|
||||
}
|
||||
}
|
|
@ -1,214 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.chat.plugins;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.simsonic.rscPermissions.MainPluginClass;
|
||||
|
||||
public class Chat_rscPermissions extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp;
|
||||
private ru.simsonic.rscPermissions.rscpAPI rscpAPI;
|
||||
|
||||
public Chat_rscPermissions(Plugin plugin, Permission perm) {
|
||||
super(perm);
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ChatServerListener(this), vault);
|
||||
if (rscp == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.rscp = (MainPluginClass) perms;
|
||||
rscpAPI = rscp.API;
|
||||
plugin.getLogger().info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class ChatServerListener implements Listener {
|
||||
|
||||
private final Chat_rscPermissions bridge;
|
||||
public ChatServerListener(Chat_rscPermissions bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
private void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.rscp == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("rscPermissions")) {
|
||||
bridge.rscp = (MainPluginClass) plugin;
|
||||
bridge.rscpAPI = bridge.rscp.API;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", vault.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.rscpAPI != null) {
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.rscpAPI.getName())) {
|
||||
bridge.rscpAPI = null;
|
||||
bridge.rscp = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", vault.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "rscPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI != null && rscpAPI.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return rscpAPI.getPlayerPrefix(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return rscpAPI.getPlayerSuffix(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return rscpAPI.getGroupPrefix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return rscpAPI.getGroupSuffix(world, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
rscpAPI.setPlayerPrefix(world, player, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
rscpAPI.setPlayerSuffix(world, player, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
rscpAPI.setGroupPrefix(world, group, prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
rscpAPI.setGroupSuffix(world, group, suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
throw new UnsupportedOperationException("rscPermissions does not support info nodes");
|
||||
}
|
||||
}
|
|
@ -1,305 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
|
||||
public class Economy_BOSE7 extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "BOSEconomy";
|
||||
private Plugin plugin = null;
|
||||
private BOSEconomy economy = null;
|
||||
|
||||
public Economy_BOSE7(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin bose = plugin.getServer().getPluginManager().getPlugin("BOSEconomy");
|
||||
if (bose != null && bose.isEnabled() && bose.getDescription().getVersion().startsWith("0.7")) {
|
||||
economy = (BOSEconomy) bose;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
if (!has(playerName, amount)) {
|
||||
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
|
||||
double balance = economy.getPlayerMoneyDouble(playerName);
|
||||
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error withdrawing funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
double balance = economy.getPlayerMoneyDouble(playerName);
|
||||
if (economy.setPlayerMoney(playerName, balance + amount, false)) {
|
||||
balance = economy.getPlayerMoneyDouble(playerName);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error depositing funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getMoneyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getMoneyName();
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_BOSE7 economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_BOSE7 economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin bose = event.getPlugin();
|
||||
|
||||
if (bose.getDescription().getName().equals("BOSEconomy") && bose.getDescription().getVersion().startsWith("0.7")) {
|
||||
economy.economy = (BOSEconomy) bose;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("BOSEconomy") && event.getPlugin().getDescription().getVersion().startsWith("0.7")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return economy.getMoneyFormatted(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
boolean success = economy.addBankOwner(name, player, false);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
boolean success = economy.removeBank(name);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove that bank account.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
double bankMoney = economy.getBankMoneyDouble(name);
|
||||
if (bankMoney < amount) {
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
} else {
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
EconomyResponse er = bankHas(name, amount);
|
||||
if (!er.transactionSuccess()) {
|
||||
return er;
|
||||
} else {
|
||||
economy.addBankMoney(name, -amount, true);
|
||||
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (!economy.bankExists(name))
|
||||
return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
else {
|
||||
economy.addBankMoney(name, amount, true);
|
||||
return new EconomyResponse(amount, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
if (!economy.bankExists(name))
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
else if (economy.isBankOwner(name, playerName)) {
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
} else
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank owner!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
} else if (economy.isBankMember(name, playerName)) {
|
||||
return new EconomyResponse(0, economy.getBankMoneyDouble(name), ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (!economy.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
double bankMoney = economy.getBankMoneyDouble(name);
|
||||
return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return economy.getBankList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.playerRegistered(playerName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (economy.playerRegistered(playerName, false)) {
|
||||
return false;
|
||||
}
|
||||
return economy.registerPlayer(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return economy.getFractionalDigits();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,234 +0,0 @@
|
|||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.github.zathrus_writer.commandsex.CommandsEX;
|
||||
import com.github.zathrus_writer.commandsex.api.economy.Economy;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
public class Economy_CommandsEX extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "CommandsEX Economy";
|
||||
private Plugin plugin = null;
|
||||
private CommandsEX economy = null;
|
||||
|
||||
public Economy_CommandsEX(Plugin plugin){
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
if (economy == null) {
|
||||
Plugin commandsex = plugin.getServer().getPluginManager().getPlugin("CommandsEX");
|
||||
|
||||
if (commandsex != null && commandsex.isEnabled()) {
|
||||
economy = (CommandsEX) commandsex;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_CommandsEX economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_CommandsEX economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin cex = event.getPlugin();
|
||||
|
||||
if (cex.getDescription().getName().equals("CommandsEX")) {
|
||||
economy.economy = (CommandsEX) cex;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("CommandsEX")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null){
|
||||
return false;
|
||||
} else {
|
||||
return Economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return Economy.getCurrencySymbol() + amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Economy.getCurrencyPlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Economy.getCurrencySingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return Economy.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return Economy.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return Economy.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
ResponseType rt;
|
||||
String message;
|
||||
|
||||
if (Economy.has(playerName, amount)){
|
||||
Economy.withdraw(playerName, amount);
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = null;
|
||||
} else {
|
||||
rt = ResponseType.FAILURE;
|
||||
message = "Not enough money";
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, Economy.getBalance(playerName), rt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
Economy.deposit(playerName, amount);
|
||||
return new EconomyResponse(amount, Economy.getBalance(playerName), ResponseType.SUCCESS, "Successfully deposited");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "CommandsEX Economy does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (Economy.hasAccount(playerName)){
|
||||
return false;
|
||||
} else {
|
||||
Economy.createAccount(playerName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,318 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.greatmancode.craftconomy3.Cause;
|
||||
import com.greatmancode.craftconomy3.Common;
|
||||
import com.greatmancode.craftconomy3.account.Account;
|
||||
import com.greatmancode.craftconomy3.groups.WorldGroupsManager;
|
||||
import com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader;
|
||||
|
||||
public class Economy_Craftconomy3 extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "Craftconomy3";
|
||||
private Plugin plugin = null;
|
||||
protected BukkitLoader economy = null;
|
||||
|
||||
public Economy_Craftconomy3(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin ec = plugin.getServer().getPluginManager().getPlugin("Craftconomy3");
|
||||
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.greatmancode.craftconomy3.BukkitLoader")) {
|
||||
economy = (BukkitLoader) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_Craftconomy3 economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_Craftconomy3 economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin ec = event.getPlugin();
|
||||
|
||||
if (ec.getDescription().getName().equals("Craftconomy3") && ec.getClass().getName().equals("com.greatmancode.craftconomy3.tools.interfaces.BukkitLoader")) {
|
||||
economy.economy = (BukkitLoader) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Craftconomy3")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return Common.getInstance().format(null, Common.getInstance().getCurrencyManager().getDefaultCurrency(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Common.getInstance().getCurrencyManager().getDefaultCurrency().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Common.getInstance().getCurrencyManager().getDefaultCurrency().getPlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return getBalance(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
return withdrawPlayer(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
return depositPlayer(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return has(playerName, WorldGroupsManager.DEFAULT_GROUP_NAME, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
boolean success = false;
|
||||
if (!Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
Common.getInstance().getAccountManager().getAccount(name,true).getAccountACL().set(player, true, true, true, true, true);
|
||||
success = true;
|
||||
}
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account. It already exists!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
boolean success = Common.getInstance().getAccountManager().delete(name, true);
|
||||
if (success) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to delete that bank account.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
Account account = Common.getInstance().getAccountManager().getAccount(name, true);
|
||||
if (account.hasEnough(amount, Common.getInstance().getServerCaller().getDefaultWorld(), Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
|
||||
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
EconomyResponse er = bankHas(name, amount);
|
||||
if (!er.transactionSuccess()) {
|
||||
return er;
|
||||
} else {
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).withdraw(amount,WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName(), Cause.VAULT, null), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).deposit(amount,WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName(), Cause.VAULT, null), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
if (Common.getInstance().getAccountManager().getAccount(name, true).getAccountACL().isOwner(playerName)) {
|
||||
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not the owner of the bank!");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
|
||||
// Basicly here if the user have access to deposit & withdraw he's a member
|
||||
EconomyResponse er = isBankOwner(name, playerName);
|
||||
if (er.transactionSuccess()) {
|
||||
return er;
|
||||
} else {
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
Account account = Common.getInstance().getAccountManager().getAccount(name, true);
|
||||
if (account.getAccountACL().canDeposit(playerName) && account.getAccountACL().canWithdraw(playerName)) {
|
||||
return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not a member of the bank!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (Common.getInstance().getAccountManager().exist(name, true)) {
|
||||
return new EconomyResponse(0, Common.getInstance().getAccountManager().getAccount(name, true).getBalance(WorldGroupsManager.DEFAULT_GROUP_NAME, Common.getInstance().getCurrencyManager().getDefaultBankCurrency().getName()), ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return Common.getInstance().getAccountManager().getAllAccounts(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return Common.getInstance().getAccountManager().exist(playerName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (Common.getInstance().getAccountManager().exist(playerName, false)) {
|
||||
return false;
|
||||
}
|
||||
Common.getInstance().getAccountManager().getAccount(playerName, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return Common.getInstance().getAccountManager().getAccount(playerName, false).getBalance(world, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return Common.getInstance().getAccountManager().getAccount(playerName, false).hasEnough(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
double balance;
|
||||
Account account = Common.getInstance().getAccountManager().getAccount(playerName, false);
|
||||
if (account.hasEnough(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
|
||||
balance = account.withdraw(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
Account account = Common.getInstance().getAccountManager().getAccount(playerName, false);
|
||||
|
||||
double balance = account.deposit(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,304 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import is.currency.Currency;
|
||||
import is.currency.syst.AccountContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_CurrencyCore extends AbstractEconomy {
|
||||
|
||||
private Currency currency;
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Plugin plugin;
|
||||
private final String name = "CurrencyCore";
|
||||
|
||||
public Economy_CurrencyCore(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if(currency == null) {
|
||||
Plugin currencyPlugin = plugin.getServer().getPluginManager().getPlugin("CurrencyCore");
|
||||
if(currencyPlugin != null && currencyPlugin.getClass().getName().equals("is.currency.Currency")) {
|
||||
this.currency = (Currency) currencyPlugin;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
|
||||
private Economy_CurrencyCore economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_CurrencyCore economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(this.economy.currency == null) {
|
||||
Plugin currencyPlugin = event.getPlugin();
|
||||
|
||||
if(currencyPlugin.getDescription().getName().equals("CurrencyCore") && currencyPlugin.getClass().getName().equals("is.currency.Currency")) {
|
||||
this.economy.currency = (Currency) currencyPlugin;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), this.economy.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (this.economy.currency != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("CurrencyCore")) {
|
||||
this.economy.currency = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), this.economy.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return currency != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return this.currency.getFormatHelper().format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return currency.getCurrencyConfig().getCurrencyMajor().get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return currency.getCurrencyConfig().getCurrencyMajor().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
|
||||
if (account == null) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return account.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
|
||||
if (account == null) {
|
||||
return false;
|
||||
} else {
|
||||
return account.hasBalance(amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
|
||||
} else if (!account.hasBalance(amount)) {
|
||||
return new EconomyResponse(0.0, account.getBalance(), ResponseType.FAILURE, "Insufficient funds");
|
||||
} else {
|
||||
account.subtractBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
|
||||
}
|
||||
account.addBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
if (this.currency.getAccountManager().hasAccount(name)) {
|
||||
return new EconomyResponse(0, currency.getAccountManager().getAccount(name).getBalance(), ResponseType.FAILURE, "That account already exists.");
|
||||
}
|
||||
this.currency.getAccountManager().createAccount(name);
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
if (this.currency.getAccountManager().hasAccount(name)) {
|
||||
this.currency.getAccountManager().deleteAccount(name);
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exists.");
|
||||
}
|
||||
return new EconomyResponse(0, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(name);
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
|
||||
} else if (!account.hasBalance(amount)) {
|
||||
return new EconomyResponse(0, account.getBalance(), ResponseType.FAILURE, "That account does not have enough!");
|
||||
} else {
|
||||
return new EconomyResponse(0, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(name);
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
|
||||
} else if (!account.hasBalance(amount)) {
|
||||
return new EconomyResponse(0, account.getBalance(), ResponseType.FAILURE, "That account does not have enough!");
|
||||
} else {
|
||||
account.subtractBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
AccountContext account = this.currency.getAccountManager().getAccount(name);
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That account does not exist!");
|
||||
} else {
|
||||
account.addBalance(amount);
|
||||
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Currency does not support Bank members.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Currency does not support Bank members.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return this.currency.getAccountManager().getAccountList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return this.currency.getAccountManager().getAccount(playerName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (this.currency.getAccountManager().getAccount(playerName) != null) {
|
||||
return false;
|
||||
}
|
||||
this.currency.getAccountManager().createAccount(playerName);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,251 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import co.uk.silvania.cities.digicoin.DigiCoin;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
public class Economy_DigiCoin extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "DigiCoin";
|
||||
private Plugin plugin = null;
|
||||
private DigiCoin economy = null;
|
||||
|
||||
public Economy_DigiCoin(Plugin plugin){
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
if (economy == null) {
|
||||
Plugin digicoin = plugin.getServer().getPluginManager().getPlugin(name);
|
||||
|
||||
if (digicoin != null && digicoin.isEnabled()) {
|
||||
economy = (DigiCoin) digicoin;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_DigiCoin economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_DigiCoin economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin digicoin = event.getPlugin();
|
||||
|
||||
if (digicoin.getDescription().getName().equals(economy.name)) {
|
||||
economy.economy = (DigiCoin) digicoin;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals(economy.name)) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
if (amount == 1.0) {
|
||||
return String.format("%d %s", amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%d %s", amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "coins";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "coin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return economy.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
ResponseType rt;
|
||||
String message;
|
||||
|
||||
if (economy.removeBalance(playerName, amount)) {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = null;
|
||||
} else {
|
||||
rt = ResponseType.FAILURE;
|
||||
message = "Not enough money.";
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, getBalance(playerName), rt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
ResponseType rt;
|
||||
String message;
|
||||
|
||||
if (economy.addBalance(playerName, amount)) {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = null;
|
||||
} else {
|
||||
rt = ResponseType.FAILURE;
|
||||
message = "Failed to deposit balance.";
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, getBalance(playerName), rt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "DigiCoin does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gravypod.Dosh.Dosh;
|
||||
import com.gravypod.Dosh.MoneyUtils;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
|
||||
public class Economy_Dosh extends AbstractEconomy {
|
||||
|
||||
|
||||
Plugin plugin;
|
||||
Dosh doshPlugin;
|
||||
DoshAPIHandler apiHandle;
|
||||
|
||||
public Economy_Dosh(Plugin _plugin) {
|
||||
plugin = _plugin;
|
||||
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("Dosh")) {
|
||||
doshPlugin = (Dosh) plugin.getServer().getPluginManager().getPlugin("Dosh");
|
||||
apiHandle = new DoshAPIHandler();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return apiHandle != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Dosh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Dosh.getSettings().moneyName + "s";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Dosh.getSettings().moneyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return DoshAPIHandler.getUserBal(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return (getBalance(playerName) - amount) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
|
||||
if (DoshAPIHandler.subtractMoney(playerName, amount)) {
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, "Worked!");
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.FAILURE, "Didnt work!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
DoshAPIHandler.addUserBal(playerName, amount);
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, "It worked!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0D, 0D, EconomyResponse.ResponseType.NOT_IMPLEMENTED, "We do not use banks!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public class DoshAPIHandler extends MoneyUtils {}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,276 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ca.agnate.EconXP.EconXP;
|
||||
|
||||
public class Economy_EconXP extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "EconXP";
|
||||
private Plugin plugin = null;
|
||||
private EconXP econ = null;
|
||||
|
||||
public Economy_EconXP(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
log.log(Level.WARNING, "EconXP is an integer only economy, you may notice inconsistencies with accounts if you do not setup your other econ using plugins accordingly!");
|
||||
// Load Plugin in case it was loaded before
|
||||
if (econ == null) {
|
||||
Plugin econ = plugin.getServer().getPluginManager().getPlugin("EconXP");
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
this.econ = (EconXP) econ;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_EconXP economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_EconXP economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.econ == null) {
|
||||
Plugin eco = event.getPlugin();
|
||||
|
||||
if (eco.getDescription().getName().equals("EconXP")) {
|
||||
economy.econ = (EconXP) eco;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.econ != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("EconXP")) {
|
||||
economy.econ = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.econ != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
|
||||
return String.format("%d %s", (int)amount, "experience");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "experience";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "experience";
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
OfflinePlayer player = econ.getPlayer(playerName);
|
||||
|
||||
if ( player == null ) { return 0; }
|
||||
|
||||
return econ.getExp(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
OfflinePlayer player = econ.getPlayer(playerName);
|
||||
|
||||
if ( player == null ) { return false; }
|
||||
|
||||
return econ.hasExp(player, (int) Math.ceil(amount) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
OfflinePlayer player = econ.getPlayer(playerName);
|
||||
|
||||
if ( player == null ) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
|
||||
}
|
||||
|
||||
double balance = econ.getExp(player);
|
||||
amount = Math.ceil(amount);
|
||||
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
if ( econ.hasExp(player, (int) amount) == false ) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
|
||||
econ.removeExp(player, (int) amount);
|
||||
|
||||
double finalBalance = econ.getExp(player);
|
||||
|
||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
OfflinePlayer player = econ.getPlayer(playerName);
|
||||
|
||||
if ( player == null ) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player does not exist");
|
||||
}
|
||||
|
||||
double balance = econ.getExp(player);
|
||||
amount = Math.ceil(amount);
|
||||
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
econ.addExp(player, (int) amount );
|
||||
balance = econ.getExp(player);
|
||||
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "EconXP does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return econ.getPlayer(playerName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,318 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.api.NoLoanPermittedException;
|
||||
import com.earth2me.essentials.api.UserDoesNotExistException;
|
||||
|
||||
public class Economy_Essentials extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Essentials Economy";
|
||||
private Plugin plugin = null;
|
||||
private Essentials ess = null;
|
||||
|
||||
public Economy_Essentials(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (ess == null) {
|
||||
Plugin essentials = plugin.getServer().getPluginManager().getPlugin("Essentials");
|
||||
if (essentials != null && essentials.isEnabled()) {
|
||||
ess = (Essentials) essentials;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (ess == null) {
|
||||
return false;
|
||||
} else {
|
||||
return ess.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
double balance;
|
||||
|
||||
try {
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
createPlayerAccount(playerName);
|
||||
balance = 0;
|
||||
}
|
||||
|
||||
return balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return com.earth2me.essentials.api.Economy.createNPC(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.subtract(playerName, amount);
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
} catch (UserDoesNotExistException e) {
|
||||
if (createPlayerAccount(playerName)) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
} else {
|
||||
amount = 0;
|
||||
balance = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "User does not exist";
|
||||
}
|
||||
} catch (NoLoanPermittedException e) {
|
||||
try {
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
amount = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "Loan was not permitted";
|
||||
} catch (UserDoesNotExistException e1) {
|
||||
amount = 0;
|
||||
balance = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "User does not exist";
|
||||
}
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
try {
|
||||
com.earth2me.essentials.api.Economy.add(playerName, amount);
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
} catch (UserDoesNotExistException e) {
|
||||
if (createPlayerAccount(playerName)) {
|
||||
return depositPlayer(playerName, amount);
|
||||
} else {
|
||||
amount = 0;
|
||||
balance = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "User does not exist";
|
||||
}
|
||||
} catch (NoLoanPermittedException e) {
|
||||
try {
|
||||
balance = com.earth2me.essentials.api.Economy.getMoney(playerName);
|
||||
amount = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "Loan was not permitted";
|
||||
} catch (UserDoesNotExistException e1) {
|
||||
balance = 0;
|
||||
amount = 0;
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
errorMessage = "Loan was not permitted";
|
||||
}
|
||||
}
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_Essentials economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_Essentials economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.ess == null) {
|
||||
Plugin essentials = event.getPlugin();
|
||||
|
||||
if (essentials.getDescription().getName().equals("Essentials")) {
|
||||
economy.ess = (Essentials) essentials;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.ess != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Essentials")) {
|
||||
economy.ess = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return com.earth2me.essentials.api.Economy.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
try {
|
||||
return com.earth2me.essentials.api.Economy.hasEnough(playerName, amount);
|
||||
} catch (UserDoesNotExistException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Essentials Eco does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return com.earth2me.essentials.api.Economy.playerExists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,316 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.flobi.GoldIsMoney2.GoldIsMoney;
|
||||
|
||||
public class Economy_GoldIsMoney2 extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "GoldIsMoney";
|
||||
private Plugin plugin = null;
|
||||
protected GoldIsMoney economy = null;
|
||||
|
||||
public Economy_GoldIsMoney2(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin ec = plugin.getServer().getPluginManager().getPlugin("GoldIsMoney");
|
||||
|
||||
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.flobi.GoldIsMoney2.GoldIsMoney")) {
|
||||
economy = (GoldIsMoney) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return GoldIsMoney.hasBankSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return GoldIsMoney.fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return GoldIsMoney.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return GoldIsMoney.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return GoldIsMoney.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return GoldIsMoney.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return GoldIsMoney.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return GoldIsMoney.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds!");
|
||||
}
|
||||
if (!GoldIsMoney.hasAccount(playerName)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not have an account!");
|
||||
}
|
||||
if (!GoldIsMoney.has(playerName, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
if (!GoldIsMoney.withdrawPlayer(playerName, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Unable to withdraw funds!");
|
||||
}
|
||||
return new EconomyResponse(amount, GoldIsMoney.getBalance(playerName), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds!");
|
||||
}
|
||||
if (!GoldIsMoney.hasAccount(playerName)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not have an account!");
|
||||
}
|
||||
if (!GoldIsMoney.depositPlayer(playerName, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.getBalance(playerName), ResponseType.FAILURE, "Unable to deposit funds!");
|
||||
}
|
||||
return new EconomyResponse(amount, GoldIsMoney.getBalance(playerName), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.createBank(name, player)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create bank account.");
|
||||
}
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.deleteBank(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove bank account.");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
if (GoldIsMoney.bankHas(name, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
if (!GoldIsMoney.bankHas(name, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
if (!GoldIsMoney.bankWithdraw(name, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "Unable to withdraw from that bank account!");
|
||||
}
|
||||
return new EconomyResponse(amount, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
if (!GoldIsMoney.bankDeposit(name, amount)) {
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.FAILURE, "Unable to deposit to that bank account!");
|
||||
}
|
||||
return new EconomyResponse(amount, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
if (!GoldIsMoney.isBankOwner(name, playerName)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player does not own that bank!");
|
||||
}
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
if (!GoldIsMoney.hasBankSupport()) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "GoldIsMoney bank support is disabled!");
|
||||
}
|
||||
if (!GoldIsMoney.bankExists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
|
||||
}
|
||||
if (!GoldIsMoney.isBankMember(name, playerName)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a member of that bank!");
|
||||
}
|
||||
return new EconomyResponse(0, GoldIsMoney.bankBalance(name), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return GoldIsMoney.getBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return GoldIsMoney.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_GoldIsMoney2 economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_GoldIsMoney2 economy_GoldIsMoney2) {
|
||||
this.economy = economy_GoldIsMoney2;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin ec = event.getPlugin();
|
||||
|
||||
if (ec.getClass().getName().equals("com.flobi.GoldIsMoney2.GoldIsMoney")) {
|
||||
economy.economy = (GoldIsMoney) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GoldIsMoney")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.igwb.GoldenChest.GoldenChestEconomy;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
public class Economy_GoldenChestEconomy extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "GoldenChestEconomy";
|
||||
private Plugin plugin = null;
|
||||
private GoldenChestEconomy economy = null;
|
||||
|
||||
|
||||
public Economy_GoldenChestEconomy (Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin ec = plugin.getServer().getPluginManager().getPlugin("GoldenChestEconomy");
|
||||
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("me.igwb.GoldenChest.GoldenChestEconomy")) {
|
||||
economy = (GoldenChestEconomy) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_GoldenChestEconomy economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_GoldenChestEconomy economy_GoldenChestEconomy) {
|
||||
this.economy = economy_GoldenChestEconomy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin ec = event.getPlugin();
|
||||
|
||||
if (ec.getDescription().getName().equals("GoldenChestEconomy") && ec.getClass().getName().equals("me.igwb.GoldenChest.GoldenChestEconomy")) {
|
||||
economy.economy = (GoldenChestEconomy) ec;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GoldenChestEconomy")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return economy.getVaultConnector().fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return economy.getVaultConnector().format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getVaultConnector().currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getVaultConnector().currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.getVaultConnector().hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return economy.getVaultConnector().hasAccount(playerName, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return economy.getVaultConnector().getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return economy.getVaultConnector().getBalance(playerName, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return economy.getVaultConnector().has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return economy.getVaultConnector().has(playerName, worldName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
if (has(playerName, amount)) {
|
||||
economy.getVaultConnector().withdrawPlayer(playerName, amount);
|
||||
return new EconomyResponse(amount, getBalance(playerName), ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse(0, getBalance(playerName), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
economy.getVaultConnector().depositPlayer(playerName, amount);
|
||||
return new EconomyResponse(amount, getBalance(playerName), EconomyResponse.ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Banks are not supported!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return economy.getVaultConnector().createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return economy.getVaultConnector().createPlayerAccount(playerName, worldName);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,271 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.gestern.gringotts.Account;
|
||||
import org.gestern.gringotts.AccountHolder;
|
||||
import org.gestern.gringotts.Gringotts;
|
||||
|
||||
public class Economy_Gringotts extends AbstractEconomy {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Gringotts";
|
||||
private Plugin plugin = null;
|
||||
private Gringotts gringotts = null;
|
||||
|
||||
public Economy_Gringotts(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
// Load Plugin in case it was loaded before
|
||||
if (gringotts == null) {
|
||||
Plugin grngts = plugin.getServer().getPluginManager().getPlugin("Gringotts");
|
||||
if (grngts != null && grngts.isEnabled()) {
|
||||
gringotts = (Gringotts) grngts;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_Gringotts economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_Gringotts economy_Gringotts) {
|
||||
this.economy = economy_Gringotts;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.gringotts == null) {
|
||||
Plugin grngts = event.getPlugin();
|
||||
|
||||
if (grngts.getDescription().getName().equals("Gringotts")) {
|
||||
economy.gringotts = (Gringotts) grngts;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.gringotts != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Gringotts")) {
|
||||
economy.gringotts = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(){
|
||||
return gringotts != null && gringotts.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return Double.toString(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural(){
|
||||
return org.gestern.gringotts.Configuration.config.currencyNamePlural;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular(){
|
||||
return org.gestern.gringotts.Configuration.config.currencyNameSingular;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
|
||||
if (owner == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return gringotts.accounting.getAccount(owner) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName){
|
||||
AccountHolder owner = gringotts.accountHolderFactory.getAccount(playerName);
|
||||
if (owner == null) {
|
||||
return 0;
|
||||
}
|
||||
Account account = gringotts.accounting.getAccount(owner);
|
||||
return account.balance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
|
||||
if( amount < 0 ) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw a negative amount.");
|
||||
}
|
||||
|
||||
AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
|
||||
if (accountHolder == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
|
||||
}
|
||||
|
||||
Account account = gringotts.accounting.getAccount( accountHolder );
|
||||
|
||||
if(account.balance() >= amount && account.remove(amount)) {
|
||||
//We has mulah!
|
||||
return new EconomyResponse(amount, account.balance(), ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
//Not enough money to withdraw this much.
|
||||
return new EconomyResponse(0, account.balance(), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount){
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
AccountHolder accountHolder = gringotts.accountHolderFactory.getAccount(playerName);
|
||||
if (accountHolder == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, playerName + " is not a valid account holder.");
|
||||
}
|
||||
|
||||
Account account = gringotts.accounting.getAccount( accountHolder );
|
||||
|
||||
if (account.add(amount)) {
|
||||
return new EconomyResponse( amount, account.balance(), ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse( 0, account.balance(), ResponseType.FAILURE, "Not enough capacity to store that amount!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "Gringotts does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,247 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import boardinggamer.mcmoney.McMoneyAPI;
|
||||
|
||||
public class Economy_McMoney extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "McMoney";
|
||||
private Plugin plugin = null;
|
||||
private McMoneyAPI economy = null;
|
||||
|
||||
public Economy_McMoney(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin econ = plugin.getServer().getPluginManager().getPlugin("McMoney");
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
economy = McMoneyAPI.getInstance();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return economy.getMoney(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
double balance = economy.getMoney(playerName);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
} else if (balance - amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
economy.removeMoney(playerName, amount);
|
||||
return new EconomyResponse(amount, economy.getMoney(playerName), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance = economy.getMoney(playerName);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
economy.addMoney(playerName, amount);
|
||||
return new EconomyResponse(amount, economy.getMoney(playerName), ResponseType.SUCCESS, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.moneyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.moneyNameSingle();
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_McMoney economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_McMoney economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin eco = event.getPlugin();
|
||||
|
||||
if (eco.getDescription().getName().equals("McMoney")) {
|
||||
economy.economy = McMoneyAPI.getInstance();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("McMoney")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
if (amount == 1) {
|
||||
return String.format("%d %s", (int)amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%d %s", (int)amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "McMoney does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return economy.playerExists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (!hasAccount(playerName)) {
|
||||
economy.setMoney(playerName, 0.0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,369 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import com.gmail.bleedobsidian.miconomy.Main;
|
||||
import com.gmail.bleedobsidian.miconomy.MiConomy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_MiConomy extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "MiConomy";
|
||||
|
||||
private Plugin plugin;
|
||||
private MiConomy economy;
|
||||
private Main miConomy;
|
||||
|
||||
public Economy_MiConomy(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (miConomy == null) {
|
||||
Plugin miConomyPlugin = plugin.getServer().getPluginManager().getPlugin("MiConomy");
|
||||
|
||||
if (miConomy != null) {
|
||||
miConomy = (Main) miConomyPlugin;
|
||||
economy = miConomy.getInstance();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if(miConomy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return miConomy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return economy.getFormattedValue(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return miConomy.getPluginConfig().MoneyNamePlural;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return miConomy.getPluginConfig().MoneyName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return hasAccount(playerName, worlds.get(0).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
return economy.isAccountCreated(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return getBalance(playerName, worlds.get(0).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String worldName) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
return economy.getAccountBalance(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return has(playerName, worlds.get(0).getName(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
double playerBalance = economy.getAccountBalance(player, world);
|
||||
|
||||
if(playerBalance >= amount) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return withdrawPlayer(playerName, worlds.get(0).getName(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
double balance = economy.getAccountBalance(player, world);
|
||||
|
||||
if(getBalance(playerName, worldName) < amount) {
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Insufficient funds");
|
||||
} else {
|
||||
if(economy.removeAccountBalance(player, amount, world)) {
|
||||
balance = economy.getAccountBalance(player, world);
|
||||
|
||||
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Failed to remove funds from account");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return depositPlayer(playerName, worlds.get(0).getName(), amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
double balance = economy.getAccountBalance(player, world);
|
||||
|
||||
if(economy.addAccountBalance(player, amount, world)) {
|
||||
balance = economy.getAccountBalance(player, world);
|
||||
|
||||
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "Failed to add funds to account");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(player);
|
||||
|
||||
ArrayList<OfflinePlayer> owners = new ArrayList<OfflinePlayer>();
|
||||
owners.add(owner);
|
||||
|
||||
if(!economy.isBankCreated(name)) {
|
||||
economy.createBank(name, owners, new ArrayList<String>(), false);
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "A bank with this name already exists");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
if(economy.isBankCreated(name)) {
|
||||
economy.deleteBank(name);
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if(economy.isBankCreated(name)) {
|
||||
double balance = economy.getBankBalance(name);
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if(economy.isBankCreated(name)) {
|
||||
double balance = economy.getBankBalance(name);
|
||||
|
||||
if(balance >= amount) {
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, EconomyResponse.ResponseType.FAILURE, "The bank does not have enough money!");
|
||||
}
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if(economy.isBankCreated(name)) {
|
||||
economy.removeBankBalance(name, amount);
|
||||
|
||||
double balance = economy.getBankBalance(name);
|
||||
|
||||
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if(economy.isBankCreated(name)) {
|
||||
economy.addBankBalance(name, amount);
|
||||
|
||||
double balance = economy.getBankBalance(name);
|
||||
|
||||
return new EconomyResponse(amount, balance, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(playerName);
|
||||
|
||||
if(economy.isBankCreated(name)) {
|
||||
if(economy.isPlayerBankOwner(name, owner)) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "The player is not a bank owner");
|
||||
}
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
OfflinePlayer owner = plugin.getServer().getOfflinePlayer(playerName);
|
||||
|
||||
if(economy.isBankCreated(name)) {
|
||||
if(economy.isPlayerBankMember(name, owner)) {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "The player is not a bank member");
|
||||
}
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, EconomyResponse.ResponseType.FAILURE, "Bank doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return economy.getBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
List<World> worlds = plugin.getServer().getWorlds();
|
||||
|
||||
return createPlayerAccount(playerName, worlds.get(0).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
World world = plugin.getServer().getWorld(worldName);
|
||||
|
||||
if(!economy.isAccountCreated(player, world)) {
|
||||
economy.createAccount(player, 0, world);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_MiConomy economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_MiConomy economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin miConomyPlugin = event.getPlugin();
|
||||
|
||||
if (miConomyPlugin.getDescription().getName().equals("MiConomy")) {
|
||||
economy.miConomy = (Main) miConomyPlugin;
|
||||
|
||||
economy.economy = miConomy.getInstance();
|
||||
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("MiConomy")) {
|
||||
economy.miConomy = null;
|
||||
economy.economy = null;
|
||||
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,272 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.mjolnir.mineconomy.MineConomy;
|
||||
import me.mjolnir.mineconomy.exceptions.AccountNameConflictException;
|
||||
import me.mjolnir.mineconomy.exceptions.NoAccountException;
|
||||
import me.mjolnir.mineconomy.internal.MCCom;
|
||||
import me.mjolnir.mineconomy.internal.util.MCFormat;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_MineConomy extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "MineConomy";
|
||||
private Plugin plugin = null;
|
||||
private MineConomy econ = null;
|
||||
|
||||
public Economy_MineConomy(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (econ == null) {
|
||||
Plugin econ = plugin.getServer().getPluginManager().getPlugin("MineConomy");
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
this.econ = (MineConomy) econ;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_MineConomy economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_MineConomy economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.econ == null) {
|
||||
Plugin eco = event.getPlugin();
|
||||
|
||||
if (eco.getDescription().getName().equals("MineConomy")) {
|
||||
economy.econ = (MineConomy) eco;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.econ != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("MineConomy")) {
|
||||
economy.econ = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "MineConomy";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return MCFormat.format(amount);
|
||||
}
|
||||
|
||||
public String currencyNameSingular() {
|
||||
return MCCom.getDefaultCurrency();
|
||||
}
|
||||
|
||||
public String currencyNamePlural() {
|
||||
return MCCom.getDefaultCurrency();
|
||||
}
|
||||
|
||||
public double getBalance(String playerName) {
|
||||
try
|
||||
{
|
||||
return MCCom.getExternalBalance(playerName);
|
||||
}
|
||||
catch (NoAccountException e)
|
||||
{
|
||||
MCCom.create(playerName);
|
||||
return MCCom.getExternalBalance(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
try {
|
||||
return MCCom.canExternalAfford(playerName, amount);
|
||||
} catch(NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
return MCCom.canExternalAfford(playerName, amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
double balance;
|
||||
try {
|
||||
balance = MCCom.getExternalBalance(playerName);
|
||||
} catch (NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
balance = MCCom.getExternalBalance(playerName);
|
||||
}
|
||||
|
||||
if(amount < 0.0D) {
|
||||
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
if(balance >= amount) {
|
||||
double finalBalance = balance - amount;
|
||||
MCCom.setExternalBalance(playerName, finalBalance);
|
||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse(0.0D, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance;
|
||||
try {
|
||||
balance = MCCom.getExternalBalance(playerName);
|
||||
} catch (NoAccountException e) {
|
||||
MCCom.create(playerName);
|
||||
balance = MCCom.getExternalBalance(playerName);
|
||||
}
|
||||
if(amount < 0.0D) {
|
||||
return new EconomyResponse(0.0D, 0.0, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
}
|
||||
|
||||
balance += amount;
|
||||
MCCom.setExternalBalance(playerName, balance);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0.0D, 0.0D, ResponseType.NOT_IMPLEMENTED, "MineConomy does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return MCCom.exists(playerName);
|
||||
}
|
||||
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
try {
|
||||
MCCom.create(playerName);
|
||||
return true;
|
||||
} catch(AccountNameConflictException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.coniin.plugins.minefaconomy.Minefaconomy;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
public class Economy_Minefaconomy extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "Minefaconomy";
|
||||
|
||||
private Plugin plugin = null;
|
||||
private Minefaconomy economy = null;
|
||||
|
||||
public Economy_Minefaconomy(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
Plugin econ = null;
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
econ = plugin.getServer().getPluginManager().getPlugin("Minefaconomy");
|
||||
log.info("Loading Minefaconomy");
|
||||
}
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
economy = (Minefaconomy) econ;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), this.name));
|
||||
return;
|
||||
}
|
||||
log.info("Error Loading Minefaconomy");
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_Minefaconomy economy_minefaconomy = null;
|
||||
|
||||
public EconomyServerListener(Economy_Minefaconomy economy_minefaconomy) {
|
||||
this.economy_minefaconomy = economy_minefaconomy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy_minefaconomy.economy == null) {
|
||||
Plugin mfc = event.getPlugin();
|
||||
|
||||
if (mfc.getDescription().getName().equals("Minefaconomy")) {
|
||||
economy_minefaconomy.economy = (Minefaconomy) economy;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy_minefaconomy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy_minefaconomy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Minefaconomy")) {
|
||||
economy_minefaconomy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy_minefaconomy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return economy != null && economy.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return Minefaconomy.vaultLayer.fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return Minefaconomy.vaultLayer.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Minefaconomy.vaultLayer.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Minefaconomy.vaultLayer.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return Minefaconomy.vaultLayer.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return Minefaconomy.vaultLayer.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return Minefaconomy.vaultLayer.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return Minefaconomy.vaultLayer.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return Minefaconomy.vaultLayer.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return Minefaconomy.vaultLayer.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return Minefaconomy.vaultLayer.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName,
|
||||
double amount) {
|
||||
return Minefaconomy.vaultLayer.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return Minefaconomy.vaultLayer.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return Minefaconomy.vaultLayer.hasBankSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return Minefaconomy.vaultLayer.createBank(name, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return Minefaconomy.vaultLayer.deleteBank(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return Minefaconomy.vaultLayer.bankBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return Minefaconomy.vaultLayer.bankHas(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return Minefaconomy.vaultLayer.bankWithdraw(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return Minefaconomy.vaultLayer.bankDeposit(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return Minefaconomy.vaultLayer.isBankOwner(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return Minefaconomy.vaultLayer.isBankMember(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return Minefaconomy.vaultLayer.getBanks();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,294 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.ashtheking.currency.Currency;
|
||||
import me.ashtheking.currency.CurrencyList;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_MultiCurrency extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "MultiCurrency";
|
||||
private Plugin plugin = null;
|
||||
private Currency economy = null;
|
||||
|
||||
public Economy_MultiCurrency(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin multiCurrency = plugin.getServer().getPluginManager().getPlugin("MultiCurrency");
|
||||
if (multiCurrency != null && multiCurrency.isEnabled()) {
|
||||
economy = (Currency) multiCurrency;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
final double balance;
|
||||
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
final double fBalance = balance;
|
||||
return fBalance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
if (amount < 0) {
|
||||
errorMessage = "Cannot withdraw negative funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
if (!CurrencyList.hasEnough(playerName, amount)) {
|
||||
errorMessage = "Insufficient funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
if (CurrencyList.subtract(playerName, amount)) {
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
} else {
|
||||
errorMessage = "Error withdrawing funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance;
|
||||
EconomyResponse.ResponseType type;
|
||||
String errorMessage = null;
|
||||
|
||||
if (amount < 0) {
|
||||
errorMessage = "Cannot deposit negative funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
|
||||
if (CurrencyList.add(playerName, amount)) {
|
||||
type = EconomyResponse.ResponseType.SUCCESS;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
} else {
|
||||
errorMessage = "Error withdrawing funds";
|
||||
type = EconomyResponse.ResponseType.FAILURE;
|
||||
amount = 0;
|
||||
balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName);
|
||||
|
||||
return new EconomyResponse(amount, balance, type, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_MultiCurrency economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_MultiCurrency economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin mcur = event.getPlugin();
|
||||
|
||||
if (mcur.getDescription().getName().equals("MultiCurrency")) {
|
||||
economy.economy = (Currency) mcur;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("MultiCurrency")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return String.format("%.2f %s", amount, "currency");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return "currency";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return "currency";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "MultiCurrency does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import com.github.omwah.SDFEconomy.SDFEconomy;
|
||||
import com.github.omwah.SDFEconomy.SDFEconomyAPI;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
public class Economy_SDFEconomy extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private Plugin plugin = null;
|
||||
|
||||
private final String name = "SDFEconomy";
|
||||
private SDFEconomyAPI api = null;
|
||||
|
||||
public Economy_SDFEconomy(Plugin _plugin) {
|
||||
plugin = _plugin;
|
||||
|
||||
// Register a listener to wait for plugin being loaded
|
||||
plugin.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Try and Load API in case plugin was loaded before Vault
|
||||
load_api();
|
||||
}
|
||||
|
||||
public void load_api() {
|
||||
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
|
||||
if(!isEnabled() && pluginSDF != null) {
|
||||
api = pluginSDF.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
public void unload_api() {
|
||||
SDFEconomy pluginSDF = (SDFEconomy) plugin.getServer().getPluginManager().getPlugin("SDFEconomy");
|
||||
if(isEnabled() && pluginSDF != null) {
|
||||
api = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_SDFEconomy economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_SDFEconomy economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
|
||||
economy.load_api();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SDFEconomy")) {
|
||||
economy.unload_api();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return api != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "SDFEconomy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return api.hasBankSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return api.fractionalDigits();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return api.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return api.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return api.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return api.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return api.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return api.has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
return api.withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
return api.depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return api.createBank(name, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return api.deleteBank(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return api.bankBalance(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return api.bankHas(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return api.bankWithdraw(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return api.bankDeposit(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return api.isBankOwner(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return api.isBankMember(name, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return api.getBankNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return api.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,259 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
import net.teamalpha.taecon.TAEcon;
|
||||
|
||||
public class Economy_TAEcon extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "TAEcon";
|
||||
private Plugin plugin = null;
|
||||
private TAEcon economy = null;
|
||||
|
||||
public Economy_TAEcon(Plugin plugin){
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
if (economy == null) {
|
||||
Plugin taecon = plugin.getServer().getPluginManager().getPlugin(name);
|
||||
|
||||
if (taecon != null && taecon.isEnabled()) {
|
||||
economy = (TAEcon) taecon;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_TAEcon economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_TAEcon economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin taecon = event.getPlugin();
|
||||
|
||||
if (taecon.getDescription().getName().equals(economy.name)) {
|
||||
economy.economy = (TAEcon) taecon;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals(economy.name)) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
if (amount == 1) {
|
||||
return String.format("%d %s", (int)amount, currencyNameSingular());
|
||||
} else {
|
||||
return String.format("%d %s", (int)amount, currencyNamePlural());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return economy.getCurrencyName(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return economy.getCurrencyName(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
return economy.getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
ResponseType rt;
|
||||
String message;
|
||||
int iamount = (int)Math.ceil(amount);
|
||||
|
||||
if (has(playerName, amount)) {
|
||||
if (economy.removeBalance(playerName, iamount)) {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = null;
|
||||
} else {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = "ERROR";
|
||||
}
|
||||
} else {
|
||||
rt = ResponseType.FAILURE;
|
||||
message = "Not enough money";
|
||||
}
|
||||
|
||||
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
ResponseType rt;
|
||||
String message;
|
||||
int iamount = (int)Math.floor(amount);
|
||||
|
||||
if (economy.addBalance(playerName, iamount)) {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = null;
|
||||
} else {
|
||||
rt = ResponseType.SUCCESS;
|
||||
message = "ERROR";
|
||||
}
|
||||
|
||||
return new EconomyResponse(iamount, getBalance(playerName), rt, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "TAEcon does not support bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,389 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.gmail.mirelatrue.xpbank.API;
|
||||
import com.gmail.mirelatrue.xpbank.Account;
|
||||
import com.gmail.mirelatrue.xpbank.GroupBank;
|
||||
import com.gmail.mirelatrue.xpbank.XPBank;
|
||||
|
||||
public class Economy_XPBank extends AbstractEconomy {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
|
||||
private final String name = "XPBank";
|
||||
private Plugin plugin = null;
|
||||
private XPBank XPB = null;
|
||||
private API api = null;
|
||||
|
||||
public Economy_XPBank (Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (XPB == null) {
|
||||
Plugin economy = plugin.getServer().getPluginManager().getPlugin("XPBank");
|
||||
if (economy != null && economy.isEnabled()) {
|
||||
XPB = (XPBank) economy;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_XPBank economy = null;
|
||||
|
||||
public EconomyServerListener (Economy_XPBank economy_XPBank) {
|
||||
this.economy = economy_XPBank;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable (PluginEnableEvent event) {
|
||||
if (economy.XPB == null) {
|
||||
Plugin eco = event.getPlugin();
|
||||
|
||||
if (eco.getDescription().getName().equals("XPBank")) {
|
||||
economy.XPB = (XPBank) eco;
|
||||
api = XPB.getAPI();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable (PluginDisableEvent event) {
|
||||
if (economy.XPB != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("XPBank")) {
|
||||
economy.XPB = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled () {
|
||||
return this.XPB != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName () {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format (double amount) {
|
||||
return String.format("%d %s", (int) amount, api.currencyName((int) amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural () {
|
||||
return api.getMsg("CurrencyNamePlural");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular () {
|
||||
return api.getMsg("currencyName");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance (String playerName) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
return account.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account.getBalance() >= (int) amount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("Player doesn't exist."));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
account.modifyBalance(-value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer (String playerName, double amount) {
|
||||
Account account = api.getAccount(playerName);
|
||||
|
||||
if (account == null) {
|
||||
// Stupid plugins that use fake players without creating them first...
|
||||
// return new EconomyResponse(0, 0, ResponseType.FAILURE, "Player doesn't exist");
|
||||
this.createPlayerAccount(playerName);
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = account.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
account.addTaxableIncome(value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank (String name, String player) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank != null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("GroupBankExists"), name));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(player);
|
||||
|
||||
groupBank = api.createGroupBank(name, account);
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
api.deleteGroupBank(groupBank, String.format(api.getMsg("Disbanded"), groupBank.getName()));
|
||||
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance (String name) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (balance >= value) {
|
||||
return new EconomyResponse(0, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
if (value > balance) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, String.format(api.getMsg("InsufficientXP"), api.currencyName(value)));
|
||||
}
|
||||
|
||||
groupBank.modifyBalance(-value);
|
||||
|
||||
return new EconomyResponse(value, balance - value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit (String name, double amount) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
int value = (int) amount;
|
||||
int balance = groupBank.getBalance();
|
||||
|
||||
if (value < 1) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, api.getMsg("LessThanZero"));
|
||||
}
|
||||
|
||||
groupBank.modifyBalance(value);
|
||||
|
||||
return new EconomyResponse(value, balance + value, ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
|
||||
if (groupBank.getOwner().equalsIgnoreCase(name)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("PlayerNotOwner"), account.getName(), groupBank.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember (String name, String playerName) {
|
||||
GroupBank groupBank = api.getGroupBank(name);
|
||||
|
||||
if (groupBank == null) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, api.getMsg("GroupBankNotExists"));
|
||||
}
|
||||
|
||||
Account account = api.getAccount(name);
|
||||
|
||||
if (account == null) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, api.getMsg("PlayerNotExist"));
|
||||
}
|
||||
|
||||
if (groupBank.groupMembers.getMembers().containsKey(playerName)) {
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
return new EconomyResponse(0, groupBank.getBalance(), ResponseType.FAILURE, String.format(api.getMsg("NotAMemberOf"), groupBank.getName(), account.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks () {
|
||||
return api.getAllGroupBanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount (String playerName) {
|
||||
api.createAccount(playerName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,253 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.ethan.eWallet.ECO;
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Economy_eWallet extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private final String name = "eWallet";
|
||||
private Plugin plugin = null;
|
||||
private ECO econ = null;
|
||||
|
||||
public Economy_eWallet(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (econ == null) {
|
||||
Plugin econ = plugin.getServer().getPluginManager().getPlugin("eWallet");
|
||||
if (econ != null && econ.isEnabled()) {
|
||||
this.econ = (ECO) econ;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_eWallet economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_eWallet economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.econ == null) {
|
||||
Plugin eco = event.getPlugin();
|
||||
|
||||
if (eco.getDescription().getName().equals("eWallet")) {
|
||||
economy.econ = (ECO) eco;
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.econ != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("eWallet")) {
|
||||
economy.econ = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.econ != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
amount = Math.ceil(amount);
|
||||
if (amount == 1) {
|
||||
return String.format("%d %s", (int)amount, econ.singularCurrency);
|
||||
} else {
|
||||
return String.format("%d %s", (int)amount, econ.pluralCurrency);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return econ.singularCurrency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return econ.pluralCurrency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
Integer i = econ.getMoney(playerName);
|
||||
return i == null ? 0 : i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= Math.ceil(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
double balance = getBalance(playerName);
|
||||
amount = Math.ceil(amount);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
} else if (balance >= amount) {
|
||||
double finalBalance = balance - amount;
|
||||
econ.takeMoney(playerName, (int) amount);
|
||||
return new EconomyResponse(amount, finalBalance, ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
double balance = getBalance(playerName);
|
||||
amount = Math.ceil(amount);
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Cannot deposit negative funds");
|
||||
} else {
|
||||
balance += amount;
|
||||
econ.giveMoney(playerName, (int) amount);
|
||||
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "eWallet does not support bank accounts!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return econ.hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
econ.createAccount(playerName, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,292 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.economy.plugins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.economy.AbstractEconomy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.iCo6.Constants;
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Accounts;
|
||||
import com.iCo6.system.Holdings;
|
||||
|
||||
public class Economy_iConomy6 extends AbstractEconomy {
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private String name = "iConomy ";
|
||||
private Plugin plugin = null;
|
||||
protected iConomy economy = null;
|
||||
private Accounts accounts;
|
||||
|
||||
public Economy_iConomy6(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EconomyServerListener(this), plugin);
|
||||
log.warning("iConomy - If you are using Flatfile storage be aware that versions 6, 7 and 8 have a CRITICAL bug which can wipe ALL iconomy data.");
|
||||
log.warning("if you're using Votifier, or any other plugin which handles economy data in a threaded manner your server is at risk!");
|
||||
log.warning("it is highly suggested to use SQL with iCo6 or to use an alternative economy plugin!");
|
||||
// Load Plugin in case it was loaded before
|
||||
if (economy == null) {
|
||||
Plugin ec = plugin.getServer().getPluginManager().getPlugin("iConomy");
|
||||
if (ec != null && ec.isEnabled() && ec.getClass().getName().equals("com.iCo6.iConomy")) {
|
||||
String version = ec.getDescription().getVersion().split("\\.")[0];
|
||||
name += version;
|
||||
economy = (iConomy) ec;
|
||||
accounts = new Accounts();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class EconomyServerListener implements Listener {
|
||||
Economy_iConomy6 economy = null;
|
||||
|
||||
public EconomyServerListener(Economy_iConomy6 economy) {
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (economy.economy == null) {
|
||||
Plugin ec = event.getPlugin();
|
||||
if (ec.getClass().getName().equals("com.iCo6.iConomy")) {
|
||||
String version = ec.getDescription().getVersion().split("\\.")[0];
|
||||
name += version;
|
||||
economy.economy = (iConomy) ec;
|
||||
accounts = new Accounts();
|
||||
log.info(String.format("[%s][Economy] %s hooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (economy.economy != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("iConomy")) {
|
||||
economy.economy = null;
|
||||
log.info(String.format("[%s][Economy] %s unhooked.", plugin.getDescription().getName(), economy.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (economy == null) {
|
||||
return false;
|
||||
} else {
|
||||
return economy.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(double amount) {
|
||||
return iConomy.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return Constants.Nodes.Major.getStringList().get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return Constants.Nodes.Major.getStringList().get(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName) {
|
||||
if (accounts.exists(playerName)) {
|
||||
return accounts.get(playerName).getHoldings().getBalance();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
Holdings holdings = accounts.get(playerName).getHoldings();
|
||||
if (holdings.hasEnough(amount)) {
|
||||
holdings.subtract(amount);
|
||||
return new EconomyResponse(amount, holdings.getBalance(), ResponseType.SUCCESS, null);
|
||||
} else {
|
||||
return new EconomyResponse(0, holdings.getBalance(), ResponseType.FAILURE, "Insufficient funds");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
Holdings holdings = accounts.get(playerName).getHoldings();
|
||||
holdings.add(amount);
|
||||
return new EconomyResponse(amount, holdings.getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, double amount) {
|
||||
return getBalance(playerName) >= amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse createBank(String name, String player) {
|
||||
if (accounts.exists(name)) {
|
||||
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "That account already exists.");
|
||||
}
|
||||
boolean created = accounts.create(name);
|
||||
if (created) {
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There was an error creating the account");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse deleteBank(String name) {
|
||||
if (accounts.exists(name)) {
|
||||
accounts.remove(name);
|
||||
return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
|
||||
}
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank account does not exist.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankHas(String name, double amount) {
|
||||
if (has(name, amount)) {
|
||||
return new EconomyResponse(0, amount, ResponseType.SUCCESS, "");
|
||||
} else {
|
||||
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.FAILURE, "The account does not have enough!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankWithdraw(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
|
||||
}
|
||||
|
||||
return withdrawPlayer(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankDeposit(String name, double amount) {
|
||||
if (amount < 0) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
|
||||
}
|
||||
|
||||
return depositPlayer(name, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankOwner(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank owners.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse isBankMember(String name, String playerName) {
|
||||
return new EconomyResponse(0, 0, ResponseType.NOT_IMPLEMENTED, "iConomy 6 does not support Bank members.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse bankBalance(String name) {
|
||||
if (!accounts.exists(name)) {
|
||||
return new EconomyResponse(0, 0, ResponseType.FAILURE, "There is no bank account with that name");
|
||||
} else {
|
||||
return new EconomyResponse(0, accounts.get(name).getHoldings().getBalance(), ResponseType.SUCCESS, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getBanks() {
|
||||
throw new UnsupportedOperationException("iConomy does not support listing of bank accounts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBankSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName) {
|
||||
return accounts.exists(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName) {
|
||||
if (hasAccount(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return accounts.create(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAccount(String playerName, String worldName) {
|
||||
return hasAccount(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(String playerName, String world) {
|
||||
return getBalance(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(String playerName, String worldName, double amount) {
|
||||
return has(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
|
||||
return withdrawPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
|
||||
return depositPlayer(playerName, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPlayerAccount(String playerName, String worldName) {
|
||||
return createPlayerAccount(playerName);
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPerms;
|
||||
import de.hydrox.bukkit.DroxPerms.DroxPermsAPI;
|
||||
|
||||
public class Permission_DroxPerms extends Permission {
|
||||
|
||||
private final String name = "DroxPerms";
|
||||
private DroxPermsAPI API;
|
||||
private boolean useOnlySubgroups;
|
||||
|
||||
public Permission_DroxPerms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (API == null) {
|
||||
DroxPerms p = (DroxPerms) plugin.getServer().getPluginManager().getPlugin("DroxPerms");
|
||||
if (p != null) {
|
||||
API = p.getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "DroxPerms"));
|
||||
useOnlySubgroups = p.getConfig().getBoolean("Vault.useOnlySubgroups", true);
|
||||
log.info(String.format("[%s][Permission] Vault.useOnlySubgroups: %s", plugin.getDescription().getName(), useOnlySubgroups));
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (API == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals("DroxPerms")) {
|
||||
API = ((DroxPerms) permPlugin).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(API != null) {
|
||||
if(event.getPlugin().getDescription().getName().equals("DroxPerms")) {
|
||||
API = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null ? p.hasPermission(permission) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return API.addPlayerPermission(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return API.removePlayerPermission(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return false; //Droxperms doesn't support direct permission checking of groups
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return API.addGroupPermission(group, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return API.removeGroupPermission(group, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return API.getPlayerGroup(player).equalsIgnoreCase(group) || API.getPlayerSubgroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (useOnlySubgroups) {
|
||||
return API.addPlayerSubgroup(player, group);
|
||||
} else {
|
||||
if ("default".equalsIgnoreCase(API.getPlayerGroup(player))) {
|
||||
return API.setPlayerGroup(player, group);
|
||||
} else {
|
||||
return API.addPlayerSubgroup(player, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (useOnlySubgroups) {
|
||||
return API.removePlayerSubgroup(player, group);
|
||||
} else {
|
||||
if (group.equalsIgnoreCase(API.getPlayerGroup(player))) {
|
||||
return API.setPlayerGroup(player, "default");
|
||||
} else {
|
||||
return API.removePlayerSubgroup(player, group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
ArrayList<String> array = API.getPlayerSubgroups(player);
|
||||
array.add(API.getPlayerGroup(player));
|
||||
return array.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return API.getPlayerGroup(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return API.getGroupNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,403 +1,361 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permission_GroupManager extends Permission {
|
||||
|
||||
private final String name = "GroupManager";
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Permission_GroupManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (groupManager == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_GroupManager permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_GroupManager permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.groupManager == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if (p.getDescription().getName().equals("GroupManager")) {
|
||||
permission.groupManager = (GroupManager) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
permission.groupManager = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return groupManager != null && groupManager.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
}
|
||||
else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.permission(playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user.addPermission(permission);
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user.removePermission(permission);
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return group.hasSamePermissionNode(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
group.addPermission(permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
group.removePermission(permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.inGroup(playerName, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
if (user.getGroup().equals(owh.getDefaultGroup())) {
|
||||
user.setGroup(group);
|
||||
} else if (group.getInherits().contains(user.getGroup().getName().toLowerCase())) {
|
||||
user.setGroup(group);
|
||||
} else {
|
||||
user.addSubGroup(group);
|
||||
}
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
boolean success = false;
|
||||
if (user.getGroup().getName().equalsIgnoreCase(groupName)) {
|
||||
user.setGroup(owh.getDefaultGroup());
|
||||
success = true;
|
||||
} else {
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group != null) {
|
||||
success = user.removeSubGroup(group);
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.getGroups(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
|
||||
}
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
|
||||
}
|
||||
|
||||
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
|
||||
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
|
||||
paInfo.getAttachment().setPermission(permission, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PermissionAttachment attach = p.addAttachment(plugin);
|
||||
attach.setPermission(permission, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
|
||||
}
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
|
||||
}
|
||||
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
|
||||
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
|
||||
return paInfo.getAttachment().getPermissions().remove(permission);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
Set<String> groupNames = new HashSet<String>();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(world.getName());
|
||||
if (owh == null) {
|
||||
continue;
|
||||
}
|
||||
Collection<Group> groups = owh.getGroupList();
|
||||
if (groups == null) {
|
||||
continue;
|
||||
}
|
||||
for (Group group : groups) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.data.Group;
|
||||
import org.anjocaido.groupmanager.data.User;
|
||||
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
public class Permission_GroupManager extends Permission {
|
||||
|
||||
private final String name = "GroupManager";
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Permission_GroupManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (groupManager == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_GroupManager permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_GroupManager permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.groupManager == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if (p.getDescription().getName().equals("GroupManager")) {
|
||||
permission.groupManager = (GroupManager) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
permission.groupManager = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return groupManager != null && groupManager.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
}
|
||||
else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.permission(playerName, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user.addPermission(permission);
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
user.removePermission(permission);
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return group.hasSamePermissionNode(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
group.addPermission(permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
group.removePermission(permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return false;
|
||||
}
|
||||
return handler.inGroup(playerName, groupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
if (user.getGroup().equals(owh.getDefaultGroup())) {
|
||||
user.setGroup(group);
|
||||
} else if (group.getInherits().contains(user.getGroup().getName().toLowerCase())) {
|
||||
user.setGroup(group);
|
||||
} else {
|
||||
user.addSubGroup(group);
|
||||
}
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return false;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
boolean success = false;
|
||||
if (user.getGroup().getName().equalsIgnoreCase(groupName)) {
|
||||
user.setGroup(owh.getDefaultGroup());
|
||||
success = true;
|
||||
} else {
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group != null) {
|
||||
success = user.removeSubGroup(group);
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
Player p = Bukkit.getPlayer(playerName);
|
||||
if (p != null) {
|
||||
GroupManager.BukkitPermissions.updatePermissions(p);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.getGroups(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
Set<String> groupNames = new HashSet<String>();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
OverloadedWorldHolder owh = groupManager.getWorldsHolder().getWorldData(world.getName());
|
||||
if (owh == null) {
|
||||
continue;
|
||||
}
|
||||
Collection<Group> groups = owh.getGroupList();
|
||||
if (groups == null) {
|
||||
continue;
|
||||
}
|
||||
for (Group group : groups) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,164 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.lightniinja.kperms.KPlayer;
|
||||
import com.lightniinja.kperms.KGroup;
|
||||
import com.lightniinja.kperms.Utilities;
|
||||
import com.lightniinja.kperms.KPermsPlugin;
|
||||
|
||||
public class Permission_KPerms extends Permission {
|
||||
|
||||
private final Plugin vault;
|
||||
private KPermsPlugin kperms = null;
|
||||
|
||||
public Permission_KPerms(Plugin plugin) {
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault);
|
||||
if (kperms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("KPerms");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.kperms = (KPermsPlugin) perms;
|
||||
plugin.getLogger().info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener implements Listener {
|
||||
private final Permission_KPerms bridge;
|
||||
|
||||
public PermissionServerListener(Permission_KPerms bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.kperms == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("KPerms")) {
|
||||
bridge.kperms = (KPermsPlugin) plugin;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", vault.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.kperms != null){
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.kperms.getName())) {
|
||||
bridge.kperms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", vault.getDescription().getName(), "KPerms"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "KPerms";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return kperms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).addPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return new KPlayer(player, kperms).removePermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).addPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return new KGroup(group, kperms).removePermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).isMemberOfGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).addGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return new KPlayer(player, kperms).removeGroup(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groups = new KPlayer(player, kperms).getGroups();
|
||||
String[] gr = new String[groups.size()];
|
||||
gr = groups.toArray(gr);
|
||||
return gr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return new KPlayer(player, kperms).getPrimaryGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new Utilities(kperms).getGroups();
|
||||
}
|
||||
}
|
|
@ -1,242 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.overmc.overpermissions.api.GroupManager;
|
||||
import com.overmc.overpermissions.api.PermissionGroup;
|
||||
import com.overmc.overpermissions.api.PermissionUser;
|
||||
import com.overmc.overpermissions.api.UserManager;
|
||||
import com.overmc.overpermissions.internal.OverPermissions;
|
||||
|
||||
public class Permission_OverPermissions extends Permission {
|
||||
private OverPermissions overPerms;
|
||||
private UserManager userManager;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Permission_OverPermissions(Plugin plugin) {
|
||||
super.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if (overPerms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if ((perms != null) && (perms.isEnabled())) {
|
||||
overPerms = ((OverPermissions) perms);
|
||||
userManager = overPerms.getUserManager();
|
||||
groupManager = overPerms.getGroupManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", new Object[] {plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName( ) {
|
||||
return "OverPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled( ) {
|
||||
return (overPerms != null) && (overPerms.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).getPermission(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).addPermissionNode(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).removePermissionNode(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
return groupManager.getGroup(groupName).getPermission(permission, worldName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (worldName == null) {
|
||||
return groupManager.getGroup(groupName).addGlobalPermissionNode(permission);
|
||||
} else {
|
||||
return groupManager.getGroup(groupName).addPermissionNode(permission, worldName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (worldName == null) {
|
||||
return groupManager.getGroup(groupName).removeGlobalPermissionNode(permission);
|
||||
} else {
|
||||
return groupManager.getGroup(groupName).removePermissionNode(permission, worldName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).getAllParents().contains(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).addParent(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
if (!groupManager.doesGroupExist(groupName)) {
|
||||
return false;
|
||||
}
|
||||
if (!userManager.canUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
return userManager.getPermissionUser(playerName).removeParent(groupManager.getGroup(groupName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String worldName, String playerName) {
|
||||
ArrayList<String> ret = new ArrayList<String>();
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return new String[0];
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
for (PermissionGroup parent : user.getAllParents()) {
|
||||
ret.add(parent.getName());
|
||||
}
|
||||
return ret.toArray(new String[ret.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
String[] playerGroups = getPlayerGroups(worldName, playerName);
|
||||
if (playerGroups.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return playerGroups[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String world, String playerName, String permission) {
|
||||
if (!userManager.doesUserExist(playerName)) { // Can't add transient permissions to an offline player.
|
||||
return false;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
return (world == null) ? user.addGlobalTransientPermissionNode(permission) : user.addTransientPermissionNode(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String world, String playerName, String permission) {
|
||||
if (!userManager.doesUserExist(playerName)) {
|
||||
return false;
|
||||
}
|
||||
PermissionUser user = userManager.getPermissionUser(playerName);
|
||||
return (world == null) ? user.removeGlobalTransientPermissionNode(permission) : user.removeTransientPermissionNode(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups( ) {
|
||||
ArrayList<String> groupNames = new ArrayList<String>();
|
||||
for (PermissionGroup s : groupManager.getGroups()) {
|
||||
groupNames.add(s.getName());
|
||||
}
|
||||
return groupNames.toArray(new String[groupNames.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat( ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport( ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public class PermissionServerListener
|
||||
implements Listener {
|
||||
Permission_OverPermissions permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_OverPermissions permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.overPerms == null) {
|
||||
Plugin perms = Permission_OverPermissions.this.plugin.getServer().getPluginManager().getPlugin("OverPermissions");
|
||||
if (perms != null) {
|
||||
permission.overPerms = ((OverPermissions) perms);
|
||||
Permission_OverPermissions.log.info(String
|
||||
.format("[%s][Permission] %s hooked.", new Object[] {Permission_OverPermissions.this.plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
if ((permission.overPerms != null) &&
|
||||
(event.getPlugin().getDescription().getName().equals("OverPermissions"))) {
|
||||
permission.overPerms = null;
|
||||
Permission_OverPermissions.log.info(String
|
||||
.format("[%s][Permission] %s un-hooked.", new Object[] {Permission_OverPermissions.this.plugin.getDescription().getName(), "OverPermissions"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,306 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.nijiko.permissions.Group;
|
||||
import com.nijiko.permissions.ModularControl;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
|
||||
public class Permission_Permissions3 extends Permission {
|
||||
|
||||
private String name = "Permissions3";
|
||||
private ModularControl perms;
|
||||
private Permissions permission = null;
|
||||
|
||||
public Permission_Permissions3(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (permission == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Permissions");
|
||||
if (perms == null) {
|
||||
plugin.getServer().getPluginManager().getPlugin("vPerms");
|
||||
name = "vPerms";
|
||||
}
|
||||
if (perms != null) {
|
||||
if (perms.isEnabled() && perms.getDescription().getVersion().startsWith("3")) {
|
||||
permission = (Permissions) perms;
|
||||
this.perms = (ModularControl) permission.getHandler();
|
||||
log.severe("Your permission system is outdated and no longer fully supported! It is highly advised to update!");
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (permission == null) {
|
||||
return false;
|
||||
} else {
|
||||
return permission.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String worldName, String playerName, String groupName) {
|
||||
return this.permission.getHandler().inGroup(worldName, playerName, groupName);
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission == null) {
|
||||
Plugin permi = event.getPlugin();
|
||||
if((permi.getDescription().getName().equals("Permissions") || permi.getDescription().getName().equals("vPerms")) && permi.getDescription().getVersion().startsWith("3")) {
|
||||
if (permi.isEnabled()) {
|
||||
permission = (Permissions) permi;
|
||||
perms = (ModularControl) permission.getHandler();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Permissions") || event.getPlugin().getDescription().getName().equals("vPerms")) {
|
||||
permission = null;
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
if (sender.isOp() || !(sender instanceof Player)) {
|
||||
return true;
|
||||
} else {
|
||||
return has(((Player) sender).getWorld().getName(), sender.getName(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(Player player, String permission) {
|
||||
return has(player.getWorld().getName(), player.getName(), permission);
|
||||
}
|
||||
|
||||
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
Group g = perms.getGroupObject(worldName, groupName);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, playerName).addParent(g);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
Group g = perms.getGroupObject(worldName, groupName);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, playerName).removeParent(g);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String worldName, String playerName, String permission) {
|
||||
this.perms.addUserPermission(worldName, playerName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String worldName, String playerName, String permission) {
|
||||
this.perms.removeUserPermission(worldName, playerName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
perms.addGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
perms.removeGroupPermission(worldName, groupName, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String worldName, String groupName, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
try {
|
||||
return perms.safeGetGroup(worldName, groupName).hasPermission(permission);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String playerName) {
|
||||
return this.perms.getGroups(world, playerName);
|
||||
}
|
||||
|
||||
public String getPrimaryGroup(String world, String playerName) {
|
||||
return getPlayerGroups(world, playerName)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String worldName, String playerName, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(playerName);
|
||||
if (p != null) {
|
||||
if (p.hasPermission(permission))
|
||||
return true;
|
||||
}
|
||||
return this.perms.has(worldName, playerName, permission);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String player, String permission) {
|
||||
return playerAddTransient(null, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(Player player, String permission) {
|
||||
return playerAddTransient(null, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, Player player, String permission) {
|
||||
return playerAddTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
try {
|
||||
perms.safeGetUser(worldName, player).addTransientPermission(permission);
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String player, String permission) {
|
||||
return playerRemoveTransient(null, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(Player player, String permission) {
|
||||
return playerRemoveTransient(null, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String worldName, Player player, String permission) {
|
||||
return playerRemoveTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
try {
|
||||
perms.safeGetUser(worldName, player).removeTransientPermission(permission);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
|
||||
Set<String> groupNames = new HashSet<String>();
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
for (Group group : perms.getGroups(world.getName())) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,237 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.platymuus.bukkit.permissions.Group;
|
||||
import com.platymuus.bukkit.permissions.PermissionInfo;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
|
||||
public class Permission_PermissionsBukkit extends Permission {
|
||||
|
||||
private final String name = "PermissionsBukkit";
|
||||
private PermissionsPlugin perms = null;
|
||||
|
||||
public Permission_PermissionsBukkit(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("PermissionsBukkit");
|
||||
if (perms != null) {
|
||||
this.perms = (PermissionsPlugin) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_PermissionsBukkit permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_PermissionsBukkit permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("PermissionsBukkit")) {
|
||||
permission.perms = (PermissionsPlugin) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("PermissionsBukkit")) {
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (perms == null) {
|
||||
return false;
|
||||
} else {
|
||||
return perms.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
if (Bukkit.getPlayer(player) != null) {
|
||||
return Bukkit.getPlayer(player).hasPermission(permission);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player setperm " + player + " " + permission + " true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player unsetperm " + player + " " + permission);
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world != null && !world.isEmpty()) {
|
||||
return perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission) == null ? false : perms.getGroup(group).getInfo().getWorldPermissions(world).get(permission);
|
||||
}
|
||||
if (perms.getGroup(group) == null) {
|
||||
return false;
|
||||
} else if (perms.getGroup(group).getInfo() == null) {
|
||||
return false;
|
||||
} else if (perms.getGroup(group).getInfo().getPermissions() == null) {
|
||||
return false;
|
||||
}
|
||||
return perms.getGroup(group).getInfo().getPermissions().get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions group setperm " + group + " " + permission + " true");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions group unsetperm " + group + " " + permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
for (Group g : perms.getPlayerInfo(player).getGroups()) {
|
||||
if (g.getName().equals(group)) {
|
||||
return g.getInfo().getWorlds().contains(world);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Group g = perms.getGroup(group);
|
||||
if (g == null) {
|
||||
return false;
|
||||
}
|
||||
return g.getPlayers().contains(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player addgroup " + player + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
return false;
|
||||
}
|
||||
return plugin.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "permissions player removegroup " + player + " " + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groupList = new ArrayList<String>();
|
||||
PermissionInfo info = perms.getPlayerInfo(player);
|
||||
if (world != null && info != null) {
|
||||
for (Group group : perms.getPlayerInfo(player).getGroups()) {
|
||||
if (group.getInfo().getWorlds().contains(world)) {
|
||||
groupList.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
if (info != null) {
|
||||
for (Group group : info.getGroups()) {
|
||||
groupList.add(group.getName());
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (perms.getPlayerInfo(player) == null) {
|
||||
return null;
|
||||
} else if (perms.getPlayerInfo(player).getGroups() != null && !perms.getPlayerInfo(player).getGroups().isEmpty() ) {
|
||||
return perms.getPlayerInfo(player).getGroups().get(0).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
List<String> groupNames = new ArrayList<String>();
|
||||
for (Group group : perms.getAllGroups()) {
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
|
||||
return groupNames.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -303,16 +303,6 @@ public class Permission_PermissionsEx extends Permission {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, String player, String permission) {
|
||||
PermissionUser pPlayer = getUser(player);
|
||||
if (pPlayer != null) {
|
||||
pPlayer.addTimedPermission(permission, worldName, 0);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, Player player, String permission) {
|
||||
|
@ -325,26 +315,11 @@ public class Permission_PermissionsEx extends Permission {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String player, String permission) {
|
||||
return playerAddTransient(null, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(Player player, String permission) {
|
||||
return playerAddTransient(null, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String worldName, String player, String permission) {
|
||||
PermissionUser pPlayer = getUser(player);
|
||||
if (pPlayer != null) {
|
||||
pPlayer.removeTimedPermission(permission, worldName);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(Player player, String permission) {
|
||||
|
@ -362,11 +337,6 @@ public class Permission_PermissionsEx extends Permission {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveTransient(String player, String permission) {
|
||||
return playerRemoveTransient(null, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
List<PermissionGroup> groups = PermissionsEx.getPermissionManager().getGroupList();
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.krinsoft.privileges.Privileges;
|
||||
import net.krinsoft.privileges.groups.Group;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Permission_Privileges extends Permission {
|
||||
|
||||
private final String name = "Privileges";
|
||||
private Privileges privs;
|
||||
|
||||
public Permission_Privileges(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (privs == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Privileges");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.privs = (Privileges) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_Privileges permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_Privileges permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.privs == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("Privileges")) {
|
||||
permission.privs = (Privileges) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.privs != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Privileges")) {
|
||||
permission.privs = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null && p.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.hasPermission(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.addPermission(world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
Group g = privs.getGroupManager().getGroup(group);
|
||||
return g != null && g.removePermission(world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null && g.isMemberOf(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
Group g = privs.getGroupManager().setGroup(player, group);
|
||||
return g != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
Group g = privs.getGroupManager().getDefaultGroup();
|
||||
return g != null && playerAddGroup(world, player, g.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
if (p == null) {
|
||||
throw new UnsupportedOperationException("Privileges does not support offline players.");
|
||||
}
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null ? g.getGroupTree().toArray(new String[g.getGroupTree().size()]) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(player);
|
||||
Group g = privs.getGroupManager().getGroup(p);
|
||||
return g != null ? g.getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (Group g : privs.getGroupManager().getGroups()) {
|
||||
groups.add(g.getName());
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,226 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyAPI;
|
||||
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permission_SimplyPerms extends Permission{
|
||||
|
||||
private final String name = "SimplyPerms";
|
||||
private SimplyAPI perms;
|
||||
|
||||
public Permission_SimplyPerms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
// Load service in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("SimplyPerms");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.perms = ((SimplyPlugin) perms).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_SimplyPerms permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_SimplyPerms permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("SimplyPerms")) {
|
||||
permission.perms = ((SimplyPlugin) perms).getAPI();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (permission.perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("SimplyPerms")) {
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
Map<String, Boolean> playerPermissions = this.perms.getPlayerPermissions(player, world);
|
||||
return playerPermissions.containsKey(permission) && playerPermissions.get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.addPlayerPermission(player, world, permission, true);
|
||||
} else {
|
||||
this.perms.addPlayerPermission(player, permission, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.removePlayerPermission(player, world, permission);
|
||||
} else {
|
||||
this.perms.removePlayerPermission(player, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
Map<String, Boolean> groupPermissions = this.perms.getGroupPermissions(group, world);
|
||||
return groupPermissions.containsKey(permission) && groupPermissions.get(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
this.perms.addGroupPermission(group, world, permission, true);
|
||||
} else {
|
||||
this.perms.addGroupPermission(group, permission, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
if (world != null) {
|
||||
permission = world + ":" + permission;
|
||||
this.perms.removeGroupPermission(group, world, permission);
|
||||
} else {
|
||||
this.perms.removeGroupPermission(group, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world != null) {
|
||||
for (String g : perms.getPlayerGroups(player)) {
|
||||
if (g.equals(group)) {
|
||||
return perms.getGroupWorlds(group).contains(world);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!perms.getAllGroups().contains(group)) {
|
||||
return false;
|
||||
}
|
||||
return perms.getPlayerGroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
group = group.toLowerCase();
|
||||
this.perms.addPlayerGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
group = group.toLowerCase();
|
||||
this.perms.removePlayerGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
List<String> groupList = new ArrayList<String>();
|
||||
if (world != null && perms.isPlayerInDB(player)) {
|
||||
for (String group : perms.getPlayerGroups(player)) {
|
||||
if (perms.getGroupWorlds(group).contains(world)) {
|
||||
groupList.add(group);
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
if (perms.isPlayerInDB(player)) {
|
||||
for (String group : perms.getPlayerGroups(player)) {
|
||||
groupList.add(group);
|
||||
}
|
||||
}
|
||||
return groupList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (!perms.isPlayerInDB(player)) {
|
||||
return null;
|
||||
} else if (perms.getPlayerGroups(player) != null && !perms.getPlayerGroups(player).isEmpty() ) {
|
||||
return perms.getPlayerGroups(player).get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return perms.getAllGroups().toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,307 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.dthielke.starburst.Group;
|
||||
import com.dthielke.starburst.GroupManager;
|
||||
import com.dthielke.starburst.GroupSet;
|
||||
import com.dthielke.starburst.StarburstPlugin;
|
||||
import com.dthielke.starburst.User;
|
||||
|
||||
public class Permission_Starburst extends Permission {
|
||||
private StarburstPlugin perms;
|
||||
private final String name = "Starburst";
|
||||
|
||||
public Permission_Starburst(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("Starburst");
|
||||
if (p != null) {
|
||||
perms = (StarburstPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if (p.getDescription().getName().equals("Starburst")) {
|
||||
perms = (StarburstPlugin) p;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("Starburst")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
String[] s = new String[perms.getGroupManager().getDefaultGroupSet().getGroups().size()];
|
||||
int i = 0;
|
||||
for (Group g : perms.getGroupManager().getDefaultGroupSet().getGroups()) {
|
||||
s[i] = g.getName();
|
||||
i++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
Set<Group> children = user.getChildren(true);
|
||||
List<String> groups = new ArrayList<String>();
|
||||
for (Group child : children) {
|
||||
groups.add(child.getName());
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
Set<Group> children = user.getChildren(false);
|
||||
if (!children.isEmpty()) {
|
||||
return children.iterator().next().getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
GroupManager gm = perms.getGroupManager();
|
||||
GroupSet set = gm.getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
g.addPermission(permission, value, true, true);
|
||||
|
||||
for (User user : gm.getAffectedUsers(g)) {
|
||||
user.applyPermissions(gm.getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
return g.hasPermission(permission, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
GroupManager gm = perms.getGroupManager();
|
||||
GroupSet set = gm.getWorldSet(Bukkit.getWorld(world));
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
|
||||
if (g.hasPermission(permission, false)) {
|
||||
g.removePermission(permission, true);
|
||||
|
||||
for (User user : gm.getAffectedUsers(g)) {
|
||||
user.applyPermissions(gm.getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms != null && perms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
user.addPermission(permission, value, true, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
if (!user.hasChild(g, false)) {
|
||||
user.addChild(g, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
|
||||
if (op.isOnline()) {
|
||||
Player p = (Player) op;
|
||||
if (p.getWorld().getName().equalsIgnoreCase(world)) {
|
||||
return p.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
Group user = set.getUser(op);
|
||||
return user.hasPermission(permission, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
return user.hasChild(g, true);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
boolean value = !permission.startsWith("^");
|
||||
permission = value ? permission : permission.substring(1);
|
||||
if (user.hasPermission(permission, false)) {
|
||||
user.removePermission(permission, true);
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||
GroupSet set = perms.getGroupManager().getWorldSet(Bukkit.getWorld(world));
|
||||
User user = set.getUser(op);
|
||||
|
||||
if (set.hasGroup(group)) {
|
||||
Group g = set.getGroup(group);
|
||||
if (user.hasChild(g, false)) {
|
||||
user.removeChild(g, true);
|
||||
|
||||
if (user.isActive()) {
|
||||
user.applyPermissions(perms.getGroupManager().getFactory());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,211 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import net.ae97.totalpermissions.PermissionManager;
|
||||
import net.ae97.totalpermissions.TotalPermissions;
|
||||
import net.ae97.totalpermissions.permission.PermissionBase;
|
||||
import net.ae97.totalpermissions.permission.PermissionUser;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permission_TotalPermissions extends Permission {
|
||||
|
||||
private final String name = "TotalPermissions";
|
||||
private PermissionManager manager;
|
||||
private TotalPermissions totalperms;
|
||||
|
||||
public Permission_TotalPermissions(Plugin pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (manager == null || totalperms == null) {
|
||||
Plugin permPlugin = event.getPlugin();
|
||||
if (permPlugin.getDescription().getName().equals(name)) {
|
||||
totalperms = (TotalPermissions) permPlugin;
|
||||
manager = totalperms.getManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (manager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals(name)) {
|
||||
totalperms = null;
|
||||
manager = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return plugin != null && plugin.isEnabled() && totalperms != null && totalperms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
return user.has(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
try {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
user.addPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
try {
|
||||
PermissionBase user = manager.getUser(player);
|
||||
user.remPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
return permGroup.has(permission, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
try {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
permGroup.addPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
try {
|
||||
PermissionBase permGroup = manager.getGroup(group);
|
||||
permGroup.remPerm(permission, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
List<String> groups = user.getGroups(world);
|
||||
return groups.contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
try {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
user.addGroup(group, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
try {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
user.remGroup(group, world);
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE,
|
||||
String.format("[%s] An error occured while saving perms", totalperms.getDescription().getName()), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
PermissionUser user = manager.getUser(player);
|
||||
List<String> groups = user.getGroups(world);
|
||||
if (groups == null) {
|
||||
groups = new ArrayList<String>();
|
||||
}
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
String[] groups = getPlayerGroups(world, player);
|
||||
if (groups.length == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return groups[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return manager.getGroups();
|
||||
}
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import com.github.sebc722.xperms.core.Main;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permission_Xperms extends Permission {
|
||||
|
||||
private final String name = "Xperms";
|
||||
private Main perms = null;
|
||||
|
||||
public Permission_Xperms(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
if(perms == null){
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("Xperms");
|
||||
if(this.perms != null){
|
||||
if(perms.isEnabled()){
|
||||
try{
|
||||
if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch(NumberFormatException e){
|
||||
// version is first release, numbered 1.0.0
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
this.perms = (Main) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_Xperms permission = null;
|
||||
|
||||
public PermissionServerListener(Permission_Xperms permission){
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (permission.perms == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
if(perms.getDescription().getName().equals("Xperms")){
|
||||
try{
|
||||
if(Double.valueOf(perms.getDescription().getVersion()) < 1.1){
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatible with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch(NumberFormatException e){
|
||||
// version is first release, numbered 1.0.0
|
||||
log.info(String.format("[%s] [Permission] %s Current version is not compatibe with vault! Please Update!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
permission.perms = (Main) perms;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(permission.perms != null){
|
||||
if(event.getPlugin().getName().equals("Xperms")){
|
||||
permission.perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), permission.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return perms.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return perms.getXplayer().hasPerm(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return perms.getXplayer().addNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return perms.getXplayer().removeNode(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return perms.getXgroup().hasPerm(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
perms.getXgroup().addNode(group, permission);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return perms.getXgroup().removeNode(group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
String groupForWorld = perms.getXplayer().getGroupForWorld(player, world);
|
||||
if(groupForWorld.equals(group)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setPlayerGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return perms.getXplayer().setPlayerDefault(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
return perms.getXplayer().getPlayerGroups(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return perms.getXplayer().getGroupForWorld(player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return perms.getXgroup().getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||
import de.bananaco.permissions.worlds.HasPermission;
|
||||
import de.bananaco.permissions.worlds.WorldPermissionsManager;
|
||||
|
||||
public class Permission_bPermissions extends Permission {
|
||||
|
||||
private final String name = "bPermissions";
|
||||
private WorldPermissionsManager perms;
|
||||
|
||||
public Permission_bPermissions(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (perms == null) {
|
||||
Plugin p = plugin.getServer().getPluginManager().getPlugin("bPermissions");
|
||||
if (p != null) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (perms == null) {
|
||||
Plugin p = event.getPlugin();
|
||||
if(p.getDescription().getName().equals("bPermissions") && p.isEnabled()) {
|
||||
perms = Permissions.getWorldPermissionsManager();
|
||||
log.info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (perms != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("bPermissions")) {
|
||||
perms = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return this.perms != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return HasPermission.has(player, world, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addPlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removePlayerNode(permission, player);
|
||||
return true;
|
||||
}
|
||||
|
||||
// use superclass implementation of playerAddTransient() and playerRemoveTransient()
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return set.getGroupNodes(group).contains(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removeNode(permission, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroups(player) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return set.getGroups(player).contains(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (set.getGroupNodes(group) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.addGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set.removeGroup(player, group);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
return groups == null ? null : groups.toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PermissionSet set = perms.getPermissionSet(world);
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> groups = set.getGroups(player);
|
||||
if (groups == null || groups.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return groups.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
throw new UnsupportedOperationException("bPermissions does not support server-wide groups");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
/* This file is part of Vault.
|
||||
|
||||
Vault is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Vault is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Vault. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.milkbowl.vault.permission.plugins;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import ru.simsonic.rscPermissions.MainPluginClass;
|
||||
|
||||
public class Permission_rscPermissions extends Permission {
|
||||
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp = null;
|
||||
private ru.simsonic.rscPermissions.rscpAPI rscpAPI = null;
|
||||
|
||||
public Permission_rscPermissions(Plugin plugin) {
|
||||
super();
|
||||
this.vault = plugin;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), vault);
|
||||
if (rscp == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
if (perms != null && perms.isEnabled()) {
|
||||
this.rscp = (MainPluginClass) perms;
|
||||
rscpAPI = rscp.API;
|
||||
plugin.getLogger().info(String.format("[%s][Permission] %s hooked.", plugin.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionServerListener implements Listener {
|
||||
private final Permission_rscPermissions bridge;
|
||||
|
||||
public PermissionServerListener(Permission_rscPermissions bridge) {
|
||||
this.bridge = bridge;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(bridge.rscp == null) {
|
||||
Plugin plugin = event.getPlugin();
|
||||
if (plugin.getDescription().getName().equals("rscPermissions")) {
|
||||
bridge.rscp = (MainPluginClass) plugin;
|
||||
bridge.rscpAPI = bridge.rscp.API;
|
||||
log.info(String.format("[%s][Permission] %s hooked.", vault.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if(bridge.rscpAPI != null){
|
||||
if(event.getPlugin().getDescription().getName().equals(bridge.rscpAPI.getName())) {
|
||||
bridge.rscpAPI = null;
|
||||
bridge.rscp = null;
|
||||
log.info(String.format("[%s][Permission] %s un-hooked.", vault.getDescription().getName(), "rscPermissions"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "rscPermissions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return rscpAPI != null && rscpAPI.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSuperPermsCompat() {
|
||||
return rscpAPI.hasSuperPermsCompat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroupSupport() {
|
||||
return rscpAPI.hasGroupSupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
return rscpAPI.playerHas(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAdd(String world, String player, String permission) {
|
||||
return rscpAPI.playerAdd(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemove(String world, String player, String permission) {
|
||||
return rscpAPI.playerRemove(world, player, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupHas(String world, String group, String permission) {
|
||||
return rscpAPI.groupHas(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupAdd(String world, String group, String permission) {
|
||||
return rscpAPI.groupAdd(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean groupRemove(String world, String group, String permission) {
|
||||
return rscpAPI.groupRemove(world, group, permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerInGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerInGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerAddGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
||||
return rscpAPI.playerRemoveGroup(world, player, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPlayerGroups(String world, String player) {
|
||||
return rscpAPI.getPlayerGroups(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String world, String player) {
|
||||
return rscpAPI.getPrimaryGroup(world, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return rscpAPI.getGroups();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue