mirror of https://github.com/MilkBowl/Vault.git
Compare commits
37 Commits
1231dde351
...
e3a664e4b3
Author | SHA1 | Date |
---|---|---|
leonardo-dgs | e3a664e4b3 | |
ILikePlayingGames | e2f919793f | |
Morgan | b2cc6bef13 | |
Morgan | 9e47e33a04 | |
Llm Dl | 31fd7b172a | |
Llm Dl | 45bcfa032a | |
Ricardo Boss | 4270d00060 | |
leonardo-dgs | 5c33e2a58b | |
Geolykt | 9ec25918cc | |
Jack | a955144229 | |
Morgan | 516c0edc96 | |
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 $?
|
150
README.md
150
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,60 @@ 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
|
||||
- SuperPerms (Bukkit's default)
|
||||
- TotalPermissions (http://dev.bukkit.org/bukkit-mods/totalpermissions)
|
||||
- XPerms
|
||||
- zPermissions
|
||||
- bPermissions
|
||||
- bPermissions 2 (https://dev.bukkit.org/projects/bpermissions)
|
||||
- DroxPerms
|
||||
- Group Manager (Essentials) (https://forums.bukkit.org/threads/15312/)
|
||||
- LuckPerms (https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-plugin.28140/)
|
||||
- OverPermissions (https://dev.bukkit.org/projects/overpermissions)
|
||||
- Permissions 3 (https://forums.bukkit.org/threads/18430/)
|
||||
- PermissionsBukkit
|
||||
- Permissions Ex (PEX) (https://forums.bukkit.org/threads/18140/)
|
||||
- Privileges
|
||||
- rscPermissions
|
||||
- SimplyPerms
|
||||
- SuperPerms (Bukkit's default)
|
||||
- TotalPermissions (https://dev.bukkit.org/projects/totalpermissions)
|
||||
- XPerms
|
||||
- zPermissions
|
||||
|
||||
* Chat
|
||||
- bPermissions
|
||||
- Group Manager (Essentials)
|
||||
- iChat
|
||||
- mChat
|
||||
- mChatSuite
|
||||
- OverPermissions
|
||||
- Permissions3
|
||||
- PEX
|
||||
- rscPermissions
|
||||
- TotalPermissions
|
||||
- zPermissions
|
||||
- bPermissions
|
||||
- Group Manager (Essentials) (https://forums.bukkit.org/threads/15312/)
|
||||
- iChat
|
||||
- LuckPerms (https://www.spigotmc.org/resources/luckperms-an-advanced-permissions-plugin.28140/)
|
||||
- mChat
|
||||
- mChatSuite
|
||||
- OverPermissions (https://dev.bukkit.org/projects/overpermissions)
|
||||
- Permissions 3 (https://forums.bukkit.org/threads/18430/)
|
||||
- Permissions Ex (PEX) (https://forums.bukkit.org/threads/18140/)
|
||||
- rscPermissions
|
||||
- TotalPermissions (https://dev.bukkit.org/projects/totalpermissions)
|
||||
- zPermissions
|
||||
|
|
|
@ -53,8 +53,8 @@
|
|||
verbose="false"
|
||||
author="true"
|
||||
version="true">
|
||||
<link href="http://docs.oracle.com/javase/7/docs/api/" />
|
||||
<link href="http://jd.bukkit.org/apidocs/" />
|
||||
<link href="https://docs.oracle.com/javase/7/docs/api/" />
|
||||
<link href="https://jd.bukkit.org/apidocs/" />
|
||||
|
||||
<classpath>
|
||||
<fileset dir="lib" includes="**/*.jar"/>
|
||||
|
|
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.
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/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.
BIN
lib/Register.jar
BIN
lib/Register.jar
Binary file not shown.
Binary file not shown.
BIN
lib/TAEcon.jar
BIN
lib/TAEcon.jar
Binary file not shown.
BIN
lib/XPBank.jar
BIN
lib/XPBank.jar
Binary file not shown.
BIN
lib/eWallet.jar
BIN
lib/eWallet.jar
Binary file not shown.
BIN
lib/iConomy6.jar
BIN
lib/iConomy6.jar
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.
|
||||
|
|
235
pom.xml
235
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"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<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 https://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>
|
||||
|
||||
|
||||
|
||||
|
@ -42,12 +40,12 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<repository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Releases</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Snapshots</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_snapshots/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
@ -55,23 +53,19 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<repository>
|
||||
<id>pub-repo</id>
|
||||
<name>Public Releases</name>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
<url>https://nexus.hc.to/content/repositories/pub_releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<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>
|
||||
<url>https://dev.escapecraft.com/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
@ -87,26 +81,17 @@ 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>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</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>
|
||||
<systemPath>${project.basedir}/lib/DroxPerms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.krinsoft</groupId>
|
||||
|
@ -116,38 +101,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -164,22 +117,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.anjocaido.groupmanager.GroupManager</groupId>
|
||||
<artifactId>GroupManager</artifactId>
|
||||
|
@ -188,22 +125,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>
|
||||
|
@ -212,22 +133,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -244,22 +149,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -300,28 +189,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -330,22 +197,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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,14 +205,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>
|
||||
|
@ -378,14 +221,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -394,14 +229,6 @@ Vault currently supports the following: Permissions 3, PEX, GroupManager, bPerms
|
|||
<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>
|
||||
|
@ -428,22 +255,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 +289,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,10 +16,7 @@
|
|||
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;
|
||||
|
@ -39,26 +36,6 @@ 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;
|
||||
|
@ -77,6 +54,8 @@ 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 +65,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,21 +75,18 @@ 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 = "";
|
||||
private double newVersion = 0;
|
||||
private double currentVersion = 0;
|
||||
private double newVersion;
|
||||
private double currentVersion;
|
||||
private String currentVersionTitle = "";
|
||||
private ServicesManager sm;
|
||||
private Metrics metrics;
|
||||
private Vault plugin;
|
||||
|
||||
@Override
|
||||
|
@ -126,14 +101,13 @@ public class Vault extends JavaPlugin {
|
|||
plugin = this;
|
||||
log = this.getLogger();
|
||||
currentVersionTitle = getDescription().getVersion().split("-")[0];
|
||||
currentVersion = Double.valueOf(currentVersionTitle.replaceFirst("\\.", ""));
|
||||
currentVersion = Double.parseDouble(currentVersionTitle.replaceFirst("\\.", ""));
|
||||
sm = getServer().getServicesManager();
|
||||
// set defaults
|
||||
getConfig().addDefault("update-check", true);
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
// Load Vault Addons
|
||||
loadEconomy();
|
||||
loadPermission();
|
||||
loadChat();
|
||||
|
||||
|
@ -142,55 +116,35 @@ public class Vault extends JavaPlugin {
|
|||
getServer().getPluginManager().registerEvents(new VaultListener(), this);
|
||||
// Schedule to check the version every 30 minutes for an update. This is to update the most recent
|
||||
// version so if an admin reconnects they will be warned about newer versions.
|
||||
this.getServer().getScheduler().runTask(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Programmatically set the default permission value cause Bukkit doesn't handle plugin.yml properly for Load order STARTUP plugins
|
||||
org.bukkit.permissions.Permission perm = getServer().getPluginManager().getPermission("vault.update");
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new org.bukkit.permissions.Permission("vault.update");
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
plugin.getServer().getPluginManager().addPermission(perm);
|
||||
}
|
||||
perm.setDescription("Allows a user or the console to check for vault updates");
|
||||
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update") && getConfig().getBoolean("update-check", true)) {
|
||||
try {
|
||||
log.info("Checking for Updates ... ");
|
||||
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");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle + " | Current Version: " + currentVersionTitle);
|
||||
} else {
|
||||
log.info("No new version available");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 432000);
|
||||
|
||||
this.getServer().getScheduler().runTask(this, () -> {
|
||||
// Programmatically set the default permission value cause Bukkit doesn't handle plugin.yml properly for Load order STARTUP plugins
|
||||
org.bukkit.permissions.Permission perm = getServer().getPluginManager().getPermission("vault.update");
|
||||
if (perm == null) {
|
||||
perm = new org.bukkit.permissions.Permission("vault.update");
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
plugin.getServer().getPluginManager().addPermission(perm);
|
||||
}
|
||||
perm.setDescription("Allows a user or the console to check for vault updates");
|
||||
|
||||
getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> {
|
||||
if (getServer().getConsoleSender().hasPermission("vault.update") && getConfig().getBoolean("update-check", true)) {
|
||||
log.info("Checking for Updates ... ");
|
||||
newVersion = updateCheck(currentVersion);
|
||||
if (newVersion > currentVersion) {
|
||||
log.warning("Stable Version: " + newVersionTitle + " is out!" + " You are still running version: " + currentVersionTitle);
|
||||
log.warning("Update at: https://dev.bukkit.org/projects/vault");
|
||||
} else if (currentVersion > newVersion) {
|
||||
log.info("Stable Version: " + newVersionTitle + " | Current Version: " + currentVersionTitle);
|
||||
}
|
||||
}
|
||||
}, 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()));
|
||||
}
|
||||
|
||||
|
@ -238,74 +192,6 @@ public class Vault extends JavaPlugin {
|
|||
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
|
||||
*/
|
||||
|
@ -357,7 +243,7 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
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."));
|
||||
log.info("[Permission] SuperPermissions loaded as backup permission system.");
|
||||
|
||||
this.perms = sm.getRegistration(Permission.class).getProvider();
|
||||
}
|
||||
|
@ -374,18 +260,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)) {
|
||||
|
@ -431,7 +305,7 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
Economy econ1 = null;
|
||||
Economy econ2 = null;
|
||||
String economies = "";
|
||||
StringBuilder economies = new StringBuilder();
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
String econName = econ.getProvider().getName().replace(" ", "");
|
||||
if (econName.equalsIgnoreCase(args[0])) {
|
||||
|
@ -440,9 +314,9 @@ public class Vault extends JavaPlugin {
|
|||
econ2 = econ.getProvider();
|
||||
}
|
||||
if (economies.length() > 0) {
|
||||
economies += ", ";
|
||||
economies.append(", ");
|
||||
}
|
||||
economies += econName;
|
||||
economies.append(econName);
|
||||
}
|
||||
|
||||
if (econ1 == null) {
|
||||
|
@ -476,37 +350,37 @@ public class Vault extends JavaPlugin {
|
|||
|
||||
private void infoCommand(CommandSender sender) {
|
||||
// Get String of Registered Economy Services
|
||||
String registeredEcons = null;
|
||||
StringBuilder registeredEcons = null;
|
||||
Collection<RegisteredServiceProvider<Economy>> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
|
||||
for (RegisteredServiceProvider<Economy> econ : econs) {
|
||||
Economy e = econ.getProvider();
|
||||
if (registeredEcons == null) {
|
||||
registeredEcons = e.getName();
|
||||
registeredEcons = new StringBuilder(e.getName());
|
||||
} else {
|
||||
registeredEcons += ", " + e.getName();
|
||||
registeredEcons.append(", ").append(e.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Get String of Registered Permission Services
|
||||
String registeredPerms = null;
|
||||
StringBuilder registeredPerms = null;
|
||||
Collection<RegisteredServiceProvider<Permission>> perms = this.getServer().getServicesManager().getRegistrations(Permission.class);
|
||||
for (RegisteredServiceProvider<Permission> perm : perms) {
|
||||
Permission p = perm.getProvider();
|
||||
if (registeredPerms == null) {
|
||||
registeredPerms = p.getName();
|
||||
registeredPerms = new StringBuilder(p.getName());
|
||||
} else {
|
||||
registeredPerms += ", " + p.getName();
|
||||
registeredPerms.append(", ").append(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
String registeredChats = null;
|
||||
StringBuilder registeredChats = null;
|
||||
Collection<RegisteredServiceProvider<Chat>> chats = this.getServer().getServicesManager().getRegistrations(Chat.class);
|
||||
for (RegisteredServiceProvider<Chat> chat : chats) {
|
||||
Chat c = chat.getProvider();
|
||||
if (registeredChats == null) {
|
||||
registeredChats = c.getName();
|
||||
registeredChats = new StringBuilder(c.getName());
|
||||
} else {
|
||||
registeredChats += ", " + c.getName();
|
||||
registeredChats.append(", ").append(c.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,9 +402,9 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
// Send user some info!
|
||||
sender.sendMessage(String.format("[%s] Vault v%s Information", getDescription().getName(), getDescription().getVersion()));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s [%s]", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s [%s]", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms));
|
||||
sender.sendMessage(String.format("[%s] Chat: %s [%s]", getDescription().getName(), chat == null ? "None" : chat.getName(), registeredChats));
|
||||
sender.sendMessage(String.format("[%s] Economy: %s %s", getDescription().getName(), econ == null ? "None" : econ.getName(), registeredEcons == null ? "" : "[" + registeredEcons + "]"));
|
||||
sender.sendMessage(String.format("[%s] Permission: %s %s", getDescription().getName(), perm == null ? "None" : perm.getName(), registeredPerms == null ? "" : "[" + registeredPerms + "]"));
|
||||
sender.sendMessage(String.format("[%s] Chat: %s %s", getDescription().getName(), chat == null ? "None" : chat.getName(), registeredChats == null ? "" : "[" + registeredChats + "]"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,56 +443,49 @@ public class Vault extends JavaPlugin {
|
|||
}
|
||||
// Pull the last version from the JSON
|
||||
newVersionTitle = ((String) ((JSONObject) array.get(array.size() - 1)).get("name")).replace("Vault", "").trim();
|
||||
return Double.valueOf(newVersionTitle.replaceFirst("\\.", "").trim());
|
||||
return Double.parseDouble(newVersionTitle.replaceFirst("\\.", "").trim());
|
||||
} catch (Exception e) {
|
||||
log.info("There was an issue attempting to check for the latest version.");
|
||||
}
|
||||
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", () -> 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", () -> 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", () -> chatName));
|
||||
}
|
||||
|
||||
public class VaultListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (perms.has(player, "vault.update")) {
|
||||
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");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Ignore exceptions
|
||||
if (newVersion > currentVersion) {
|
||||
player.sendMessage("Vault " + newVersionTitle + " is out! You are running " + currentVersionTitle);
|
||||
player.sendMessage("Update Vault at: " + VAULT_BUKKIT_URL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -16,8 +16,8 @@ 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 Logger log;
|
||||
private final String name = "DroxPerms";
|
||||
private Plugin plugin;
|
||||
private DroxPermsAPI API;
|
||||
|
@ -25,6 +25,7 @@ public class Chat_DroxPerms extends Chat {
|
|||
public Chat_DroxPerms(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
// Load Plugin in case it was loaded before
|
||||
if (API == null) {
|
||||
|
|
|
@ -1,367 +1,362 @@
|
|||
/* 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.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.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_GroupManager extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final String name = "GroupManager - Chat";
|
||||
private Plugin plugin = null;
|
||||
private GroupManager groupManager;
|
||||
|
||||
public Chat_GroupManager(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 (groupManager == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
groupManager = (GroupManager) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_GroupManager chat = null;
|
||||
|
||||
public PermissionServerListener(Chat_GroupManager chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.groupManager == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms.getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (groupManager == null) {
|
||||
return false;
|
||||
} else {
|
||||
return groupManager.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String worldName, String playerName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Integer val = handler.getUserPermissionInteger(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String worldName, String playerName, String node, int value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String worldName, String groupName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Integer val = handler.getGroupPermissionInteger(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String worldName, String groupName, String node, int value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String worldName, String playerName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Double val = handler.getUserPermissionDouble(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String worldName, String playerName, String node, double value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String worldName, String groupName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Double val = handler.getGroupPermissionDouble(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String worldName, String groupName, String node, double value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String worldName, String playerName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = handler.getUserPermissionBoolean(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String worldName, String playerName, String node, boolean value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String worldName, String groupName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
Boolean val = handler.getGroupPermissionBoolean(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String worldName, String groupName, String node, boolean value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String worldName, String playerName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getUserPermissionString(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String worldName, String playerName, String node, String value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String worldName, String groupName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getGroupPermissionString(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String worldName, String groupName, String node, String value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserPrefix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserSuffix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String worldName, String player, String suffix) {
|
||||
setPlayerInfoString(worldName, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String worldName, String player, String prefix) {
|
||||
setPlayerInfoString(worldName, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String worldName, String group, String prefix) {
|
||||
setGroupInfoString(worldName, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String worldName, String group, String suffix) {
|
||||
setGroupInfoString(worldName, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
private void setPlayerValue(String worldName, String playerName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
user.getVariables().addVar(node, value);
|
||||
}
|
||||
|
||||
private void setGroupValue(String worldName, String groupName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
group.getVariables().addVar(node, value);
|
||||
}
|
||||
}
|
||||
/* 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.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.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_GroupManager extends Chat {
|
||||
|
||||
private final Logger log;
|
||||
private final String name = "GroupManager - Chat";
|
||||
private final Plugin plugin;
|
||||
private GroupManager groupManager;
|
||||
|
||||
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
|
||||
if (groupManager == null) {
|
||||
Plugin chat = plugin.getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (chat != null) {
|
||||
if (chat.isEnabled()) {
|
||||
groupManager = (GroupManager) chat;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
|
||||
Chat_GroupManager chat;
|
||||
|
||||
public PermissionServerListener(Chat_GroupManager chat) {
|
||||
this.chat = chat;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (chat.groupManager == null) {
|
||||
Plugin perms = event.getPlugin();
|
||||
|
||||
if (perms.getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = (GroupManager) perms;
|
||||
log.info(String.format("[%s][Chat] %s hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPluginDisable(PluginDisableEvent event) {
|
||||
if (chat.groupManager != null) {
|
||||
if (event.getPlugin().getDescription().getName().equals("GroupManager")) {
|
||||
chat.groupManager = null;
|
||||
log.info(String.format("[%s][Chat] %s un-hooked.", plugin.getDescription().getName(), chat.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (groupManager == null) {
|
||||
return false;
|
||||
} else {
|
||||
return groupManager.isEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerInfoInteger(String worldName, String playerName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionInteger(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoInteger(String worldName, String playerName, String node, int value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGroupInfoInteger(String worldName, String groupName, String node, int defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionInteger(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoInteger(String worldName, String groupName, String node, int value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPlayerInfoDouble(String worldName, String playerName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionDouble(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoDouble(String worldName, String playerName, String node, double value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getGroupInfoDouble(String worldName, String groupName, String node, double defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionDouble(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoDouble(String worldName, String groupName, String node, double value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerInfoBoolean(String worldName, String playerName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getUserPermissionBoolean(playerName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoBoolean(String worldName, String playerName, String node, boolean value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGroupInfoBoolean(String worldName, String groupName, String node, boolean defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
return handler.getGroupPermissionBoolean(groupName, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String worldName, String groupName, String node, boolean value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String worldName, String playerName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getUserPermissionString(playerName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerInfoString(String worldName, String playerName, String node, String value) {
|
||||
setPlayerValue(worldName, playerName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupInfoString(String worldName, String groupName, String node, String defaultValue) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
String val = handler.getGroupPermissionString(groupName, node);
|
||||
return val != null ? val : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoString(String worldName, String groupName, String node, String value) {
|
||||
setGroupValue(worldName, groupName, node, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerPrefix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserPrefix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerSuffix(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
if (handler == null) {
|
||||
return "";
|
||||
}
|
||||
return handler.getUserSuffix(playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerSuffix(String worldName, String player, String suffix) {
|
||||
setPlayerInfoString(worldName, player, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerPrefix(String worldName, String player, String prefix) {
|
||||
setPlayerInfoString(worldName, player, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupPrefix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupPrefix(String worldName, String group, String prefix) {
|
||||
setGroupInfoString(worldName, group, "prefix", prefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroupSuffix(String worldName, String group) {
|
||||
return getGroupInfoString(worldName, group, "suffix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupSuffix(String worldName, String group, String suffix) {
|
||||
setGroupInfoString(worldName, group, "suffix", suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryGroup(String worldName, String playerName) {
|
||||
AnjoPermissionsHandler handler;
|
||||
if (worldName == null) {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissionsByPlayerName(playerName);
|
||||
} else {
|
||||
handler = groupManager.getWorldsHolder().getWorldPermissions(worldName);
|
||||
}
|
||||
return handler.getGroup(playerName);
|
||||
}
|
||||
|
||||
private void setPlayerValue(String worldName, String playerName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getWorldDataByPlayerName(playerName);
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
User user = owh.getUser(playerName);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
user.getVariables().addVar(node, value);
|
||||
}
|
||||
|
||||
private void setGroupValue(String worldName, String groupName, String node, Object value) {
|
||||
OverloadedWorldHolder owh;
|
||||
if (worldName == null) {
|
||||
owh = groupManager.getWorldsHolder().getDefaultWorld();
|
||||
} else {
|
||||
owh = groupManager.getWorldsHolder().getWorldData(worldName);
|
||||
}
|
||||
if (owh == null) {
|
||||
return;
|
||||
}
|
||||
Group group = owh.getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
group.getVariables().addVar(node, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ 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 final Logger log;
|
||||
private String name = "Permissions 3 (Yeti) - Chat";
|
||||
private PermissionHandler perms;
|
||||
private Plugin plugin = null;
|
||||
|
@ -42,6 +42,7 @@ public class Chat_Permissions3 extends Chat {
|
|||
public Chat_Permissions3(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
|
|
|
@ -34,15 +34,16 @@ 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;
|
||||
private final Plugin plugin;
|
||||
private PermissionsEx chat = null;
|
||||
|
||||
public Chat_PermissionsEx(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
@ -59,7 +60,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_PermissionsEx chat = null;
|
||||
Chat_PermissionsEx chat;
|
||||
|
||||
public PermissionServerListener(Chat_PermissionsEx chat) {
|
||||
this.chat = chat;
|
||||
|
@ -220,9 +221,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoInteger(String world, String groupName, String node, int value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -240,9 +239,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoDouble(String world, String groupName, String node, double value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -260,9 +257,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
|
@ -280,9 +275,7 @@ public class Chat_PermissionsEx extends Chat {
|
|||
@Override
|
||||
public void setGroupInfoString(String world, String groupName, String node, String value) {
|
||||
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
|
||||
if (group == null) {
|
||||
return;
|
||||
} else {
|
||||
if (group != null) {
|
||||
group.setOption(node, world, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,14 +32,15 @@ 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 final Logger log;
|
||||
private Plugin plugin = null;
|
||||
InfoReader chat;
|
||||
|
||||
public Chat_bPermissions(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
|
|
@ -32,14 +32,15 @@ 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;
|
||||
private final Plugin plugin;
|
||||
private boolean hooked;
|
||||
|
||||
public Chat_bPermissions2(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Chat_bPermissions2 chat = null;
|
||||
Chat_bPermissions2 chat;
|
||||
|
||||
public PermissionServerListener(Chat_bPermissions2 chat) {
|
||||
this.chat = chat;
|
||||
|
@ -139,8 +140,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -158,8 +158,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
int i = Integer.valueOf(s);
|
||||
return i;
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -177,8 +176,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -196,8 +194,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
double d = Double.valueOf(s);
|
||||
return d;
|
||||
return Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
@ -214,8 +211,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
return Boolean.parseBoolean(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,20 +226,19 @@ public class Chat_bPermissions2 extends Chat {
|
|||
if (s == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
Boolean val = Boolean.valueOf(s);
|
||||
return val != null ? val : defaultValue;
|
||||
return Boolean.parseBoolean(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
ApiLayer.setValue(world, CalculableType.GROUP, group, node, String.valueOf(value));;
|
||||
ApiLayer.setValue(world, CalculableType.GROUP, group, node, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
String val = ApiLayer.getValue(world, CalculableType.USER, player, node);
|
||||
return (val == null || val == "BLANKWORLD" || val == "") ? defaultValue : val;
|
||||
return (val == null || val.equals("BLANKWORLD") || val.equals("")) ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -254,7 +249,7 @@ public class Chat_bPermissions2 extends Chat {
|
|||
@Override
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
String val = ApiLayer.getValue(world, CalculableType.GROUP, group, node);
|
||||
return (val == null || val == "BLANKWORLD" || val == "") ? defaultValue : val;
|
||||
return (val == null || val.equals("BLANKWORLD") || val.equals("")) ? defaultValue : val;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class Chat_iChat extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Logger log;
|
||||
private final String name = "iChat";
|
||||
private Plugin plugin = null;
|
||||
private iChatAPI iChat = null;
|
||||
|
@ -41,6 +41,7 @@ public class Chat_iChat extends Chat {
|
|||
public Chat_iChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ 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 Logger log;
|
||||
private final String name = "mChat";
|
||||
private Plugin plugin = null;
|
||||
private mChatAPI mChat = null;
|
||||
|
@ -39,6 +39,7 @@ public class Chat_mChat extends Chat {
|
|||
public Chat_mChat(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(this), plugin);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ 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 Logger log;
|
||||
private final String name = "mChatSuite";
|
||||
private Plugin plugin = null;
|
||||
private mChatSuite mChat = null;
|
||||
|
@ -42,6 +42,7 @@ public class Chat_mChatSuite extends Chat {
|
|||
public Chat_mChatSuite(Plugin plugin, Permission perms) {
|
||||
super(perms);
|
||||
this.plugin = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new PermissionServerListener(), plugin);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ import ru.simsonic.rscPermissions.MainPluginClass;
|
|||
|
||||
public class Chat_rscPermissions extends Chat {
|
||||
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private final Logger log;
|
||||
private final Plugin vault;
|
||||
private ru.simsonic.rscPermissions.MainPluginClass rscp;
|
||||
private ru.simsonic.rscPermissions.rscpAPI rscpAPI;
|
||||
|
@ -40,6 +40,7 @@ public class Chat_rscPermissions extends Chat {
|
|||
public Chat_rscPermissions(Plugin plugin, Permission perm) {
|
||||
super(perm);
|
||||
this.vault = plugin;
|
||||
this.log = plugin.getLogger();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new ChatServerListener(this), vault);
|
||||
if (rscp == null) {
|
||||
Plugin perms = plugin.getServer().getPluginManager().getPlugin("rscPermissions");
|
||||
|
|
|
@ -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,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;
|
||||
|
||||
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<>();
|
||||
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,242 +1,224 @@
|
|||
/* 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"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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 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"}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,12 +224,6 @@ public class Permission_Permissions3 extends Permission {
|
|||
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);
|
||||
|
@ -240,8 +234,7 @@ public class Permission_Permissions3 extends Permission {
|
|||
return playerAddTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean playerAddTransient(String worldName, String player, String permission) {
|
||||
private boolean playerAddTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
@ -253,33 +246,15 @@ public class Permission_Permissions3 extends Permission {
|
|||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
return pRemoveTransient(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;
|
||||
}
|
||||
return pRemoveTransient(worldName, player.getName(), permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -303,4 +278,18 @@ public class Permission_Permissions3 extends Permission {
|
|||
public boolean hasGroupSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean pRemoveTransient(String worldName, String player, String permission) {
|
||||
if (worldName == null) {
|
||||
worldName = "*";
|
||||
}
|
||||
|
||||
try {
|
||||
perms.safeGetUser(worldName, player).removeTransientPermission(permission);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import ru.tehkode.permissions.bukkit.PermissionsEx;
|
|||
public class Permission_PermissionsEx extends Permission {
|
||||
|
||||
private final String name = "PermissionsEx";
|
||||
private PermissionsEx permission = null;
|
||||
private PermissionsEx permission;
|
||||
|
||||
public Permission_PermissionsEx(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -48,7 +48,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
if (perms != null) {
|
||||
if (perms.isEnabled()) {
|
||||
try {
|
||||
if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
|
||||
if (Double.parseDouble(perms.getDescription().getVersion()) < 1.16) {
|
||||
log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -71,7 +71,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
}
|
||||
|
||||
public class PermissionServerListener implements Listener {
|
||||
Permission_PermissionsEx permission = null;
|
||||
Permission_PermissionsEx permission;
|
||||
|
||||
public PermissionServerListener(Permission_PermissionsEx permission) {
|
||||
this.permission = permission;
|
||||
|
@ -83,7 +83,7 @@ public class Permission_PermissionsEx extends Permission {
|
|||
Plugin perms = event.getPlugin();
|
||||
if (perms.getDescription().getName().equals("PermissionsEx")) {
|
||||
try {
|
||||
if (Double.valueOf(perms.getDescription().getVersion()) < 1.16) {
|
||||
if (Double.parseDouble(perms.getDescription().getVersion()) < 1.16) {
|
||||
log.info(String.format("[%s][Permission] %s below 1.16 is not compatible with Vault! Falling back to SuperPerms only mode. PLEASE UPDATE!", plugin.getDescription().getName(), name));
|
||||
return;
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -41,7 +41,7 @@ public class Permission_SuperPerms extends Permission {
|
|||
@Override
|
||||
public boolean playerHas(String world, String player, String permission) {
|
||||
Player p = plugin.getServer().getPlayer(player);
|
||||
return p != null ? p.hasPermission(permission) : false;
|
||||
return p != null && p.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,7 @@ import de.bananaco.bpermissions.api.CalculableType;
|
|||
public class Permission_bPermissions2 extends Permission {
|
||||
|
||||
private final String name = "bPermissions2";
|
||||
private boolean hooked = false;
|
||||
private boolean hooked;
|
||||
|
||||
public Permission_bPermissions2(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
@ -180,8 +180,8 @@ public class Permission_bPermissions2 extends Permission {
|
|||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
String[] groups = null;
|
||||
Set<String> gSet = new HashSet<String>();
|
||||
String[] groups;
|
||||
Set<String> gSet = new HashSet<>();
|
||||
for(World world : WorldManager.getInstance().getAllWorlds()) {
|
||||
Set<Calculable> gr = world.getAll(CalculableType.GROUP);
|
||||
for(Calculable c : gr) {
|
||||
|
@ -189,7 +189,7 @@ public class Permission_bPermissions2 extends Permission {
|
|||
}
|
||||
}
|
||||
// Convert to String
|
||||
groups = gSet.toArray(new String[gSet.size()]);
|
||||
groups = gSet.toArray(new String[0]);
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue