Merge master into dev

This commit is contained in:
GeorgH93 2020-05-16 00:39:42 +02:00
commit 95934489fb
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
21 changed files with 651 additions and 150 deletions

51
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,51 @@
# This workflow will run every time a new release is created.
# It will first build the plugin using Maven, then publish it to GitHub packages and finally attach the artifacts to the release
name: Maven build and deploy on release
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup workspace
run: mkdir artifacts
- name: Build with Maven
run: |
mvn -B install package --file pom.xml
cp Minepacks/target/M*.jar artifacts/
- name: Publish to GitHub Packages Apache Maven
run: 'mvn deploy -pl Minepacks-API,Minepacks -s $GITHUB_WORKSPACE/settings.xml "-DaltDeploymentRepository=github::default::https://maven.pkg.github.com/GeorgH93/Minepacks"'
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Build with Maven (Standalone)
run: |
mvn -B clean install package --file pom.xml -P Standalone,ExcludeBadRabbit
mv Minepacks/target/M*-Standalone.jar artifacts/
- name: Build with Maven (Release)
run: |
mvn -B clean package --file pom.xml -P Release
mv Minepacks/target/M*-Release.jar artifacts/
- name: Upload the artifacts
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'artifacts/M*'

View File

@ -43,9 +43,10 @@ cd Minepacks
mvn -pl Minepacks-API mvn -pl Minepacks-API
``` ```
## Usage:
### Get access to the API: ### Get access to the API:
```java ```java
public MinepacksPlugin getMinepacks() { public static MinepacksPlugin getMinepacks() {
Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks"); Plugin bukkitPlugin = Bukkit.getPluginManager().getPlugin("Minepacks");
if(!(bukkitPlugin instanceof MinepacksPlugin)) { if(!(bukkitPlugin instanceof MinepacksPlugin)) {
// Do something if Minepacks is not available // Do something if Minepacks is not available
@ -56,6 +57,16 @@ public MinepacksPlugin getMinepacks() {
``` ```
You can now use the returned `MinepacksPlugin` object to interact with the Minepacks plugin. You can now use the returned `MinepacksPlugin` object to interact with the Minepacks plugin.
### Access a players backpack inventory:
```java
public static Inventory getPlayerBackpackInventory(Player player) {
Backpack bp = getMinepacks().getBackpackCachedOnly(player);
if(bp == null) return null; //Backpack not loaded (retry later)
return bp.getInventory();
}
```
This will return null if the backpack is not loaded or the inventory of the backpack if the backpack is already loaded.
## Links: ## Links:
* [JavaDoc][apiJavaDoc] * [JavaDoc][apiJavaDoc]
* [API Build Server][apiBuilds] * [API Build Server][apiBuilds]

View File

@ -23,6 +23,8 @@
<dependencies>PCGF_PluginLib</dependencies> <dependencies>PCGF_PluginLib</dependencies>
<soft-dependencies/> <soft-dependencies/>
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass> <mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}</mainClass>
<releaseType>Normal</releaseType>
<updateChannel>Release</updateChannel>
</properties> </properties>
<dependencies> <dependencies>
@ -36,8 +38,7 @@
<dependency> <dependency>
<groupId>at.pcgamingfreaks</groupId> <groupId>at.pcgamingfreaks</groupId>
<artifactId>PluginLib</artifactId> <artifactId>PluginLib</artifactId>
<version>1.0.23-SNAPSHOT</version> <version>1.0.25-SNAPSHOT</version> </dependency>
</dependency>
<!-- BadRabbit --> <!-- BadRabbit -->
<dependency> <dependency>
<groupId>at.pcgamingfreaks</groupId> <groupId>at.pcgamingfreaks</groupId>
@ -141,6 +142,7 @@
<version>${project.version}-Standalone</version> <version>${project.version}-Standalone</version>
<dependencies/> <dependencies/>
<mainClass>${project.groupId}.${project.artifactId}Standalone.Bukkit.${project.artifactId}</mainClass> <mainClass>${project.groupId}.${project.artifactId}Standalone.Bukkit.${project.artifactId}</mainClass>
<releaseType>Standalone</releaseType>
</properties> </properties>
<build> <build>
<plugins> <plugins>
@ -235,6 +237,7 @@
<dependencies/> <dependencies/>
<soft-dependencies>PCGF_PluginLib</soft-dependencies> <soft-dependencies>PCGF_PluginLib</soft-dependencies>
<mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}BadRabbit</mainClass> <mainClass>${project.groupId}.${project.artifactId}.Bukkit.${project.artifactId}BadRabbit</mainClass>
<releaseType>Release</releaseType>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>

View File

@ -2,7 +2,7 @@
# Language Settings # Language Settings
Language: Language:
# Defines the used language and the corresponding file used. The corresponding language file will be placed in the lang folder next to the config.yml named: <Language>.yml # Defines the used language, and the corresponding file used. The corresponding language file will be placed in the lang folder next to the config.yml named: <Language>.yml
Language: en Language: en
# Options: # Options:
# Overwrite (deletes all changes from the file and extracts a new language file) # Overwrite (deletes all changes from the file and extracts a new language file)
@ -36,11 +36,11 @@ Cooldown:
# Defines how long a player have to wait till he can reopen his backpack. # Defines how long a player have to wait till he can reopen his backpack.
# Time is in seconds. Values < 1 disable the cooldown. # Time is in seconds. Values < 1 disable the cooldown.
Command: -1 Command: -1
# If enabled, cooldowns will be synced between servers (BungeeCord network). It will also allow to keep cooldown through server restarts. # If enabled, cooldowns will be synced between servers (BungeeCord network). It will also allow keeping the cooldown through server restarts.
# You should only use it with long cooldown times. # You should only use it with long cooldown times.
Sync: false Sync: false
AddOnJoin: true AddOnJoin: true
# You can turn this on when using sync to reduce the memory consumption a little bit # You can turn this on when using sync to reduce the memory consumption a little
ClearOnLeave: false ClearOnLeave: false
# Removes old cooldowns from the cache to free memory. Time in seconds. # Removes old cooldowns from the cache to free memory. Time in seconds.
CleanupInterval: 600 CleanupInterval: 600
@ -87,11 +87,11 @@ Database:
Properties: [] Properties: []
# Tables settings for shared tables when using MySQL - Advanced MySQL Settings # Tables settings for shared tables when using MySQL - Advanced MySQL Settings
# Use these settings only if you know what you are doing!!!! # Use these settings only if you know what you are doing!!!!
# Do only change this settings if you know what you are doing and have some basic MySQL knowledge!!! # Do only change these settings if you know what you are doing and have some basic MySQL knowledge!!!
# Changing settings down here after you have used this plugin may result in data inconsistency!!! # Changing settings down here after you have used this plugin may result in data inconsistency!!!
Tables: Tables:
# Table names # Table names
# Don't change the players table if you have backpacks stored in your database already! Player id's might wont match anymore resulting data inconsistency. # Don't change the players table if you have backpacks stored in your database already! Player id's might won't match anymore resulting data inconsistency.
User: backpack_players User: backpack_players
Backpack: backpacks Backpack: backpacks
Cooldown: backpack_cooldowns Cooldown: backpack_cooldowns
@ -111,32 +111,32 @@ Database:
Cooldown: Cooldown:
Player_ID: id Player_ID: id
Time: time Time: time
# Settings controlling the cache behavior of the plugin. You may can optimize it a little bit depending on your player count, ram or cpu bottlenecks. # Settings controlling the cache behavior of the plugin. You may optimize it a little depending on your player count, ram or cpu bottlenecks.
Cache: Cache:
UnCache: UnCache:
# The strategie used to uncache offline players. Options # The strategie used to uncache offline players. Options
# interval (offline players get uncached every x seconds) # interval (offline players get uncached every x seconds)
# intervalChecked (like interval, but also ensures that the player is already offline for at least the interval time, add's a cpu overhead) # intervalChecked (like interval, but also ensures that the player is already offline for at least the interval time, adds a cpu overhead)
# ondisconnect (player instantly gets uncached as soon as he disconnects, may adds overhead if other plugins try to access the player data when they go offline, also it may be problematic for players with unstable connections) # ondisconnect (player instantly gets uncached as soon as he disconnects, may adds overhead if other plugins try to access the player data when they go offline, also it may be problematic for players with unstable connections)
# ondisconnectdelayed (player gets uncached x seconds after he went offline, adds overhead on disconnect, you shouldn't use this with a lot of players joining and leaving.) # ondisconnectdelayed (player gets uncached x seconds after he went offline, adds overhead on disconnect, you shouldn't use this with a lot of players joining and leaving.)
Strategie: interval Strategie: interval
# Used for the interval based uncaching algorithms. Also used as delay for ondisconnectdelayed. Value in seconds. Default: 600 = 10 minutes # Used for the interval based uncaching algorithms, and is also used as delay for ondisconnectdelayed. Value in seconds. Default: 600 = 10 minutes
Interval: 600 Interval: 600
Delay: 600 Delay: 600
Shulkerboxes: Shulkerboxes:
# This setting controls whether players can put shulkerboxes into their backpacks. # This setting controls whether players can put shulkerboxes into their backpacks.
PreventInBackpack: true PreventInBackpack: true
# This setting allows to disable shulkerboxes all together. Players won't be able to craft or use them. # This setting allows disabling shulkerboxes all together. Players won't be able to craft or use them.
DisableShulkerboxes: false DisableShulkerboxes: false
# This settings controls how existing shulkerboxes are handled if they are disabled. # This setting controls how existing shulkerboxes are handled if they are disabled.
# Options: Ignore, Remove = shulker-box will be removed including it's content, Destroy = shulker-box will be destroyed and it's content will be dropped # Options: Ignore, Remove = shulker-box will be removed including its content, Destroy = shulker-box will be destroyed, and it's content will be dropped
Existing: "Ignore" Existing: "Ignore"
ItemFilter: ItemFilter:
# Enables the item filter. Make sure to define items to be filtered. # Enables the item filter. Make sure to define items to be filtered.
Enabled: false Enabled: false
# Changes the filter mode, either blacklist (only not listed materials are allowed) or whitelist (only listed materials are allowed) # Changes the filter mode, either blacklist (only unlisted materials are allowed) or whitelist (only listed materials are allowed)
Mode: blacklist Mode: blacklist
# Filter lists bellow. An item will be blocked (in blacklist mode) or allowed (in whitelist mode) if it matches on of the given filters. # Filter lists bellow. An item will be blocked (in blacklist mode) or allowed (in whitelist mode) if it matches on of the given filters.
# List of materials that should be filtered. Can be name or id (id only for MC versions older than 1.13!). # List of materials that should be filtered. Can be name or id (id only for MC versions older than 1.13!).
@ -146,7 +146,7 @@ ItemFilter:
# List of lore that should be filtered. Can be a single line or all lines of the lore. # List of lore that should be filtered. Can be a single line or all lines of the lore.
Lore: [] Lore: []
# This settings allow control over how the plugin behave in different worlds # These settings allow control over how the plugin behave in different worlds
WorldSettings: WorldSettings:
# All worlds listed here will not have the plugin usable # All worlds listed here will not have the plugin usable
# Blacklist: ["creative_world"] # Blacklist: ["creative_world"]
@ -154,14 +154,14 @@ WorldSettings:
Blacklist: [] Blacklist: []
# Defines how the Blacklist will be enforced # Defines how the Blacklist will be enforced
# Options: # Options:
# Message = The player will see a message that the usage of the backpack is denied in this world. # Message = The player will see a message that the usage of the backpack is not allowed in this world.
# MissingPermission = The player will receive the plugins no permission message. # MissingPermission = The player will receive the plugins no permission message.
# NoPlugin = The plugin will not be available at all and act as if it was not installed. # NoPlugin = The plugin will not be available at all and act as if it was not installed.
# This also exclude players with permission to bypass the world restriction from using it! # This also exclude players with permission to bypass the world restriction from using it!
# It will not disable the Shulkerboxes filter! # It will not disable the Shulkerboxes filter!
BlacklistMode: "Message" BlacklistMode: "Message"
# Gives the players an item that they can interact with to open their backpack. Only works on MC 1.8 or newer # Gives the players an item they can interact with to open their backpack. Only works on MC 1.8 or newer.
ItemShortcut: ItemShortcut:
# If enabled the players will be given an item they can interact with to open the backpack. # If enabled the players will be given an item they can interact with to open the backpack.
# The item may not be removed from their inventory as long as this option is enabled. # The item may not be removed from their inventory as long as this option is enabled.
@ -170,7 +170,7 @@ ItemShortcut:
AllowPlayersToChoseItem: true AllowPlayersToChoseItem: true
# Allows players to disable the backpack item. Only effective if AllowPlayersToChoseItem is enabled. # Allows players to disable the backpack item. Only effective if AllowPlayersToChoseItem is enabled.
AllowPlayersToDisableItem: true AllowPlayersToDisableItem: true
# Increases compatibility with some death chest plugins. Enable this if the backpack item is added to your death chest! # Increases compatibility with some death chest plugins. Enable this if the backpack item gets added to your death chest!
ImproveDeathChestCompatibility: false ImproveDeathChestCompatibility: false
# Prevents the backpack from being used as a hat # Prevents the backpack from being used as a hat
BlockAsHat: false BlockAsHat: false
@ -178,17 +178,19 @@ ItemShortcut:
OpenContainerOnRightClick: false OpenContainerOnRightClick: false
# The id of the slot that should be preferred when giving a player the shortcut item # The id of the slot that should be preferred when giving a player the shortcut item
PreferredSlotId: -1 PreferredSlotId: -1
# If this option is enabled the player will not be able to move the backpack item within their inventory
BlockItemFromMoving: false
Sound: Sound:
# Enables all sound effects # Enables all sound effects
Enabled: true Enabled: true
# The sound effect that should be played if the backpack is opened # The sound effect that should be played when the backpack is opened
# disabled or false to disable the sound effect # disabled or false to disable the sound effect
# auto will play the chest sound for minecraft versions older than 1.11 and the shulker-box sound for newer MC versions # auto will play the chest sound for minecraft versions older than 1.11, and the shulker-box sound for newer MC versions
OpenSound: auto OpenSound: auto
# The sound effect that should be played if the backpack is closed # The sound effect that should be played when the backpack is closed
# disabled or false to disable the sound effect # disabled or false to disable the sound effect
# auto will play the chest sound for minecraft versions older than 1.11 and the shulker-box sound for newer MC versions # auto will play the chest sound for minecraft versions older than 1.11, and the shulker-box sound for newer MC versions
CloseSound: auto CloseSound: auto
# Settings for the inventory management # Settings for the inventory management
@ -198,10 +200,12 @@ InventoryManagement:
Enabled: true Enabled: true
Misc: Misc:
# Enables/Disables the auto-update function of the plugin. AutoUpdate:
AutoUpdate: true # When auto update is disabled you still can use the build in update function manually with /backpack update
Enabled: true
Channel: ${updateChannel}
# Enable this option if you are using a BungeeCord setup! # Enable this option if you are using a BungeeCord setup!
UseBungeeCord: false UseBungeeCord: false
# Config file version. Don't touch it! # Config file version. Don't touch it!
Version: 29 Version: 31

View File

@ -1,30 +1,118 @@
#simple-Chinese # To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at
Language: Language:
Console: NotFromConsole: "§f§b背包§f 控制台无法执行这个命令。"
Enabled: MinePacks插件当前已启用!
Disabled: MinePacks插件当前未启用.
NotFromConsole: 无法在控制台中使用此命令.
LangUpdated: 语言配置文件已更新.
UpdateUUIDs: 更新UUID数据中...
UpdatedUUIDs: "%s个UUID数据已更新完成."
MinecraftVersionNotCompatible: "你的Minecraft版本(MC %1$s)当前不兼容本插件的当前版本(%2$s). 请更新!"
Ingame: Ingame:
NoPermission: 您没有权限使用. NoPermission: "§f§b背包§f 您没有权限。"
OwnBackPackClose: 您的背包已关闭. WorldDisabled: "§f§b背包§f 这个世界禁用。"
PlayerBackPackClose: "%s的背包已关闭." NaN: "§f§b背包§f 无效的数值。"
InvalidBackpack: 无效背包. OwnBackpackClose: "§f§b背包§f 背包关闭"
BackpackCleaned: 背包已清理. OwnBackpackClose_SendMethod: "action_bar"
Cooldown: 请等待冷却时间结束后再开启您的背包. #Parameter: {OwnerName}, {OwnerDisplayName}
WrongGameMode: 在当前游戏模式下,您不被允许使用背包. PlayerBackpackClose: "§f§b背包§f 玩家 §a{OwnerName} §f背包关闭。"
PlayerBackpackClose_SendMethod: "action_bar"
InvalidBackpack: "§f§b背包§f 无效的背包。"
NotAllowedInBackpack: "§f§b背包§f 物品 {ItemName} §f不能放背包内。"
NotAllowedInBackpack_SendMethod: "action_bar"
DontRemoveShortcut: "§f§b背包§f 您不能从背包丢弃头颅。"
DontRemoveShortcut_SendMethod: "action_bar"
Open:
#Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened
Cooldown: "§f§b背包§f 请等待 §e{TimeLeft} §f秒。"
#Parameter: {CurrentGameMode}, {AllowedGameModes}
WrongGameMode: "§f§b背包§f 您不能在这种游戏模式下打开背包。"
Clean:
BackpackCleaned: "§f§b背包§f 背包清空。"
BackpackCleanedBy: "§f§b背包§f 玩家 {DisplayName} 清空您的背包。"
BackpackCleanedOther: "§f§b背包§f 玩家 {DisplayName} 的背包已清空。"
Sort:
Sorted: "§f§b背包§f 背包分类"
Help:
Header: ""
Footer: ""
Reload:
Reloading: "§f§b背包§f 重新加载中"
Reloaded: "§f§b背包§f 更新配置与语言文件"
Update:
CheckingForUpdates: "§f§b背包§f 检查更新"
Updated: "§f§b背包§f 插件已更新,将在下次启动加载。"
NoUpdate: "§f§b背包§f 没有可用的更新。"
UpdateFail: "§f§b背包§f 出现错误!请检查控制台!"
# You can change this message if you like to, but don't cry if the link isn't linking to the plugin anymore!
UpdateAvailable: "§f§b背包§f 发现新版本 https://www.spigotmc.org/resources/19286/"
Backup:
Created: "§f§b背包§f 背包已备份"
NoBackpack: "§f§b背包§f 玩家没有背包,或者背包是空的。"
Restore:
BackupsPerPage: 10
Headline: "[\"\",{\"text\":\"Backups\",\"color\":\"yellow\"},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"showing page {CurrentPage}/{MaxPage}\",\"color\":\"gold\"}]"
Footer: "[{\"text\":\"<<< Previous <<<\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"}},{\"text\":\" Showing page {CurrentPage}/{MaxPage} \",\"color\":\"gold\"},{\"text\":\">>> Next >>>\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"}}]"
BackupEntry: "[\"\",{\"text\":\"{BackupIdentifier}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand} {BackupIdentifier}\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"User: {BackupPlayerName} ({BackupPlayerUUID})\\nCreated: {BackupDate}\"}}]"
NoValidBackup: "No backup matching {BackupIdentifier} found"
NoUserToRestoreToFound: "No valid user to restore backup to found"
# No Json!!!
ParameterBackupName: "backup_name"
# No Json!!!
DateFormat: "yyyy.MM.dd HH:mm:ss"
Restored: "Backup has been successful restored."
InventoryClear:
UnknownPlayer: "&cCould not find player {Name}!"
Cleared: "Inventory cleared."
ClearedOther: "{DisplayName}'s&r inventory has been cleared."
ClearedOtherTarget: "Your inventory has been cleared by {DisplayName}&r."
Commands:
HelpFormat: "§f§b背包§f {Description}命令 “/{MainCommand} {SubCommand} {Parameters}”"
PlayerNameVariable: "player_name"
Description: Description:
Backpack: 打开您自己的背包. Backpack: "打开背包"
Clean: 清理您自己的背包. Sort: "整理背包"
CleanOther: 清理其他玩家的背包. Clean: "清空背包"
View: 查看其他玩家的背包. CleanOthers: "清空玩家背包"
OpenOthers: "显示玩家背包"
Reload: "重新加载"
Update: "检查更新"
Version: "查看版本"
Backup: "创建备份"
Restore: "打开备份"
RestoreList: "列出所有备份"
Help: "查看帮助"
Migrate: "迁移数据类型"
Command:
Backpack:
- backpack
- bp
Open:
- open
Sort:
- sort
Clean:
- clean
- clear
- empty
Reload:
- reload
- restart
Update:
- update
Backup:
- backup
Restore:
- restore
ListBackups:
- listbackups
Version:
- version
Help:
- help
InventoryClear:
- clear
- inventoryclear
- clean
# Will be shown in the console during startup # Will be shown in the console during startup
LanguageName: "simple-chinese" LanguageName: "中文"
Author: "ragnaroks" Author: ""
# Language file version. Don't touch it! # Language file version. Don't touch it!
Version: 5 Version: 18

View File

@ -1,4 +1,4 @@
# To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at # To simplify the customisation and translation process please check out the editor: https://ptp.pcgamingfreaks.at
Language: Language:
NotFromConsole: "&cDieser Befehl kann nicht in der Konsole ausgeführt werden." NotFromConsole: "&cDieser Befehl kann nicht in der Konsole ausgeführt werden."
@ -21,7 +21,7 @@ Language:
BackpackCleanedOther: "Der Rucksack von {DisplayName}&r wurde geleert." BackpackCleanedOther: "Der Rucksack von {DisplayName}&r wurde geleert."
Open: Open:
#Parameter: {TimeLeft} time in seconds till he can reopen his backpack #Parameter: {TimeLeft} time in seconds till he can reopen his backpack
Cooldown: "&2Bitte warte noch {TimeLeft} Sekunden bis du deinen Rucksack wieder öffnest." Cooldown: "&2Bitte warte noch {TimeLeft} Sekunden, bis du deinen Rucksack wieder öffnest."
#Parameter: {CurrentGameMode}, {AllowedGameModes} #Parameter: {CurrentGameMode}, {AllowedGameModes}
WrongGameMode: "Du darfst deinen Rucksack in deinem aktuellem Gamemode nicht öffnen." WrongGameMode: "Du darfst deinen Rucksack in deinem aktuellem Gamemode nicht öffnen."
Sort: Sort:
@ -82,9 +82,9 @@ Language:
Clean: "Leert deinen Rucksack." Clean: "Leert deinen Rucksack."
CleanOthers: "Leert den Rucksack eines anderen Spielers." CleanOthers: "Leert den Rucksack eines anderen Spielers."
OpenOthers: "Öffnet den Rucksack eines anderen Spielers." OpenOthers: "Öffnet den Rucksack eines anderen Spielers."
Reload: "Lädt die Konfigurations-Datei neu." Reload: "Lädt die Konfigurationsdatei neu."
Update: "Prüft auf neue Plugin-Updates." Update: "Prüft auf neue Plugin-Updates."
Backup: "Erstellt eine Sicherungskopie eines Rucksackes." Backup: "Erstellt eine Sicherungskopie eines Rucksacks."
Restore: "Stellt eine Sicherungskopie eines Rucksacks wieder her." Restore: "Stellt eine Sicherungskopie eines Rucksacks wieder her."
RestoreList: "Listet alle verfügbaren Sicherungskopien von Rucksäcken auf." RestoreList: "Listet alle verfügbaren Sicherungskopien von Rucksäcken auf."
Version: "Gibt die Versionsdetails über das Plugin und seine Abhängigkeiten aus." Version: "Gibt die Versionsdetails über das Plugin und seine Abhängigkeiten aus."

View File

@ -1,4 +1,4 @@
# To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at # To simplify the customisation and translation process please check out the editor: https://ptp.pcgamingfreaks.at
Language: Language:
NotFromConsole: "&cCommand not usable from console." NotFromConsole: "&cCommand not usable from console."

View File

@ -13,13 +13,20 @@ Language:
PlayerBackpackClose_SendMethod: "action_bar" PlayerBackpackClose_SendMethod: "action_bar"
InvalidBackpack: "Sac à dos non valide." InvalidBackpack: "Sac à dos non valide."
NotAllowedInBackpack: "&c{ItemName} n'est pas autorisé dans le sac à dos." NotAllowedInBackpack: "&c{ItemName} n'est pas autorisé dans le sac à dos."
NotAllowedInBackpack_SendMethod: "action_bar"
DontRemoveShortcut: "&cVous ne devez pas supprimer le raccourci de sac à dos de votre inventaire !"
DontRemoveShortcut_SendMethod: "action_bar"
Open: Open:
#Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened #Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened
Cooldown: "[{\"text\":\"Veuillez patienter \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} secondes\"}},{\"text\":\" till you reopen your backpack.\"}]" Cooldown: "[{\"text\":\"Veuillez patienter \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} secondes\"}},{\"text\":\" till you reopen your backpack.\"}]"
#Parameter: {CurrentGameMode}, {AllowedGameModes} #Parameter: {CurrentGameMode}, {AllowedGameModes}
WrongGameMode: "Vous n'êtes pas autorisé à ouvrir votre sac à dos dans votre mode de jeu actuel." WrongGameMode: "Vous n'êtes pas autorisé à ouvrir votre sac à dos dans votre mode de jeu actuel."
Clean: Clean:
BackpackCleaned: "Sac à dos nettoyé." BackpackCleaned: "Sac à dos nettoyé."s
BackpackCleanedBy: "Votre sac à dos a été nettoyé par {DisplayName}&r."
BackpackCleanedOther: "Sac à dos de {DisplayName} &rnettoyé."
Sort:
Sorted: "Sac à dos trié."
Help: Help:
Header: "&6### Minepacks Commandes ###" Header: "&6### Minepacks Commandes ###"
Footer: "&6#############################" Footer: "&6#############################"
@ -48,11 +55,17 @@ Language:
# No Json!!! # No Json!!!
DateFormat: "dd.MM.yyyy HH:mm:ss" DateFormat: "dd.MM.yyyy HH:mm:ss"
Restored: "La sauvegarde a été restaurée avec succès." Restored: "La sauvegarde a été restaurée avec succès."
InventoryClear:
UnknownPlayer: "&cImpossible de trouver le joueur {Name}!"
Cleared: "Inventaire nettoyé."
ClearedOther: "Inventaire de {DisplayName} &rnettoyé."
ClearedOtherTarget: "Votre inventaire a été effacé par {DisplayName}&r."
Commands: Commands:
HelpFormat: "[\"\",{\"text\":\"/{MainCommand} {SubCommand} {Parameters}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand}\"}},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"{Description}\",\"color\":\"aqua\"}]" HelpFormat: "[\"\",{\"text\":\"/{MainCommand} {SubCommand} {Parameters}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand}\"}},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"{Description}\",\"color\":\"aqua\"}]"
PlayerNameVariable: "player_name" PlayerNameVariable: "player_name"
Description: Description:
Backpack: "Ouvre votre sac à dos." Backpack: "Ouvre votre sac à dos."
Sort: "Trie votre sac à dos."
Clean: "Nettoie votre sac à dos." Clean: "Nettoie votre sac à dos."
CleanOthers: "Nettoie le sac à dos d'un autre joueur." CleanOthers: "Nettoie le sac à dos d'un autre joueur."
OpenOthers: "Montre le sac à dos d'un autre joueur." OpenOthers: "Montre le sac à dos d'un autre joueur."
@ -71,6 +84,8 @@ Command:
- bp - bp
Open: Open:
- open - open
Sort:
- sort
Clean: Clean:
- clean - clean
- clear - clear
@ -90,10 +105,14 @@ Command:
- version - version
Help: Help:
- help - help
InventoryClear:
- clear
- inventoryclear
- clean
# Will be shown in the console during startup # Will be shown in the console during startup
LanguageName: "Français" LanguageName: "Français"
Author: "HiiRaZ" Author: "HiiRaZ & Sniper_TVmc"
# Language file version. Don't touch it! # Language file version. Don't touch it!
Version: 16 Version: 18

View File

@ -1,28 +1,122 @@
Version: 18
# To simplify the customisation and the translation process please check out the editor: http://ptp.pcgamingfreaks.at
Language: Language:
Console: NotFromConsole: "&cDit commando kan je niet vanuit de console gebruiken."
Enabled: MinePacks is ingeschakeld!
Disabled: MinePacks is uitgeschakeld.
NotFromConsole: Commando kan niet in de console worden gebruikt.
LangUpdated: Taal Bestand is geüpdatet.
UpdateUUIDs: Beginnen met updaten van database naar UUIDs ...
UpdatedUUIDs: '%s accounts geüpdatet naar UUIDs.'
Ingame: Ingame:
NoPermission: Je bent niet bevoegd om dit te doen. NoPermission: "&cJe bent niet gemachtigd om dat te doen."
OwnBackPackClose: 'Rugzak gesloten!' WorldDisabled: "&cHet gebruik van de rugzak is niet toegestaan in deze wereld."
PlayerBackPackClose: "%s's rugzak gesloten!" NaN: "[\"\",{\"text\":\"De ingevoerde waarde moet een getal zijn!\",\"color\":\"red\"}]"
InvalidBackpack: Ongeldige rugzak. OwnBackpackClose: "Rugzak gesloten"
BackpackCleaned: Rugzak schoongemaakt. OwnBackpackClose_SendMethod: "action_bar"
Cooldown: "Wacht alsjeblieft met het heropenen van je rugzak." # Parameter: {OwnerName}, {OwnerDisplayName}
WrongGameMode: "Je bent niet bevoegd om je rugzak in je huidige spelmodus te openen." PlayerBackpackClose: "{OwnerName}'s rugzak gesloten"
PlayerBackpackClose_SendMethod: "action_bar"
InvalidBackpack: "Ongeldige rugzak"
NotAllowedInBackpack: "&c{ItemName} mag je niet in de rugzak bewaren."
NotAllowedInBackpack_SendMethod: "action_bar"
DontRemoveShortcut: "&cJe mag de rugzak niet uit je inventaris halen!"
DontRemoveShortcut_SendMethod: "action_bar"
Open:
# Parameter: {TimeLeft} time in seconds till the backpack can be reopened, {TimeSpanLeft} time formatted as string till the backpack can be reopened
Cooldown: "[{\"text\":\"Wacht \",\"color\":\"dark_green\"},{\"text\":\"{TimeSpanLeft}\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"{TimeLeft} seconds\"}},{\"text\":\" voordat je de rugzak heropent.\"}]"
# Parameter: {CurrentGameMode}, {AllowedGameModes}
WrongGameMode: "De rugzak mag in de huidige spelmodus niet worden geopend."
Clean:
BackpackCleaned: "Rugzak geleegd"
BackpackCleanedBy: "Je rugzak is geleegd door {DisplayName}&r."
BackpackCleanedOther: "{DisplayName}'s&r rugzak is geleegd."
Sort:
Sorted: "Rugzak gesorteerd."
Help:
Header: "&6### Minepacks Commando's ###"
Footer: "&6#############################"
Reload:
Reloading: "&1Minepacks opnieuw laden"
Reloaded: "&1Minepacks is herladen"
Update:
CheckingForUpdates: "&1Controleren op updates"
Updated: "[\"\",{\"text\":\"Plugin geüpdatet, veranderingen zijn van kracht na de volgende herstart.\",\"color\":\"yellow\"}]"
NoUpdate: "[\"\",{\"text\":\"Geen plugin update beschikbaar.\",\"color\":\"gold\"}]"
UpdateFail: "[\"\",{\"text\":\"Er was een probleem bij het zoeken naar updates. Bekijk de console!\",\"color\":\"red\"}]"
# You can change this message if you like to, but don't cry if the link isn't linking to the plugin anymore!
UpdateAvailable: "[{\"text\":\"Er is een update beschikbaar! Ga naar \\\"\",\"color\":\"green\"},{\"text\":\"${project.url}\",\"color\":\"yellow\",\"underlined\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"${project.url}\"}},{\"text\":\"\\\" om hem te downloaden!\"}]"
Backup:
Created: "De rugzak is succesvol opgeslagen."
NoBackpack: "De speler heeft geen rugzak of deze is leeg."
Restore:
BackupsPerPage: "10"
Headline: "[\"\",{\"text\":\"Back-ups\",\"color\":\"yellow\"},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"Pagina {CurrentPage} van {MaxPage}\",\"color\":\"gold\"}]"
Footer: "[{\"text\":\"<<< Vorige <<<\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}--\"}},{\"text\":\" Pagina {CurrentPage} van {MaxPage} \",\"color\":\"gold\"},{\"text\":\">>> Volgende >>>\",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"/{MainCommand} {SubCommand} {CurrentPage}++\"}}]"
BackupEntry: "[\"\",{\"text\":\"{BackupIdentifier}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand} {BackupIdentifier}\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"User: {BackupPlayerName} ({BackupPlayerUUID})\\nCreated: {BackupDate}\"}}]"
NoValidBackup: "Geen back-up gevonden die overeenkomt met {BackupIdentifier}."
NoUserToRestoreToFound: "Geen geldige speler gevonden waarbij de back-up kan worden hersteld."
# No Json!!!
ParameterBackupName: "backup_name"
# No Json!!!
DateFormat: "d MMMM yyyy HH:mm[:ss]"
Restored: "Back-up is succesvol hersteld."
InventoryClear:
UnknownPlayer: "&cKan speler {Name} niet vinden!"
Cleared: "Inventaris geleegd"
ClearedOther: "{DisplayName}'s&r inventaris is geleegd."
ClearedOtherTarget: "Je inventaris is geleegd door {DisplayName}&r."
Commands:
HelpFormat: "[\"\",{\"text\":\"/{MainCommand} {SubCommand} {Parameters}\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/{MainCommand} {SubCommand}\"}},{\"text\":\" - \",\"color\":\"white\"},{\"text\":\"{Description}\",\"color\":\"aqua\"}]"
PlayerNameVariable: "player_name"
Description: Description:
Backpack: Opent je rugzak. Backpack: "Opent je rugzak."
Clean: Maakt je rugzak schoon. Sort: "Sorteert je rugzak."
CleanOther: Maakt de rugzak van andere spelers schoon. Clean: "Schoont je rugzak op."
View: Laat de rugzak van andere spelers zien. CleanOthers: "Schoont de rugzak op van andere spelers."
OpenOthers: "Laat de rugzak zien van andere spelers."
# Will be shown in the console during startup Reload: "Herlaadt de instellingen van de plugin."
LanguageName: "dutch" Update: "Controleert op nieuwe plugin updates."
Author: "bramvkempen" Version: "Geeft details weer over de versie de plugin en diens afhankelijkheden."
Backup: "Creëert een back-up van de rugzakken van de spelers."
# Taal Bestand versie. Niet aan komen! Restore: "Herstelt een back-up."
Version: 5 RestoreList: "Laat alle beschikbare back-ups zien."
Help: "Laat alle commando's zien met hun beschrijving."
Migrate: "Zet de database over naar een ander type."
LanguageName: "Nederlands"
Author: "Le0ne_"
Command:
Backpack:
- backpack
- bp
- rugzak
- rz
Open:
- open
Sort:
- sorteer
- sort
Clean:
- clean
- schoon
Reload:
- herlaad
- herstart
- reload
- restart
Update:
- update
Backup:
- backup
Restore:
- restore
- herstel
ListBackups:
- listbackups
- lijst
- backuplijst
Version:
- version
- versie
Help:
- help
- hulp
InventoryClear:
- clear
- inventoryclear
- wis
- verwijder

View File

@ -0,0 +1,55 @@
UpdateProviders:
Bukkit:
Type: Bukkit
ProjectId: 83445
Spigot:
Type: Spigot
ProjectId: 19286
Filename: "minepacks.jar"
GitHub:
Type: GitHub
Owner: GeorgH93
Repo: Minepacks
GitHubStandalone:
Type: GitHub
Owner: GeorgH93
Repo: Minepacks
JarSearch: ".*-Standalone\\.jar"
GitHubRelease:
Type: GitHub
Owner: GeorgH93
Repo: Minepacks
JarSearch: ".*-Release\\.jar"
JenkinsMaster:
Type: Jenkins
Server: "https://ci.pcgamingfreaks.at"
Job: "Minepacks"
JenkinsMasterStandalone:
Type: Jenkins
Server: "https://ci.pcgamingfreaks.at"
Job: "Minepacks"
Filter: ".*-Standalone.jar"
JenkinsMasterRelease:
Type: Jenkins
Server: "https://ci.pcgamingfreaks.at"
Job: "Minepacks"
Filter: ".*-Release.jar"
JenkinsDev:
Type: Jenkins
Server: "https://ci.pcgamingfreaks.at"
Job: "Minepacks Dev"
UpdateChannels:
Release:
Release: [ Bukkit, Spigot, GitHubRelease ]
Standalone: [ GitHubStandalone ]
Normal: [ GitHub ]
Master:
Release: [ JenkinsMasterRelease ]
Standalone: [ JenkinsMasterStandalone ]
Normal: [ JenkinsMaster ]
Dev:
Normal: [ JenkinsDev ]
DefaultChannel: "${updateChannel}"
ReleaseType: "${releaseType}"

View File

@ -39,8 +39,7 @@
public class Config extends Configuration implements DatabaseConnectionConfiguration public class Config extends Configuration implements DatabaseConnectionConfiguration
{ {
private static final int CONFIG_VERSION = 29, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20; private static final int CONFIG_VERSION = 31, UPGRADE_THRESHOLD = CONFIG_VERSION, PRE_V2_VERSION = 20;
public Config(JavaPlugin plugin) public Config(JavaPlugin plugin)
{ {
super(plugin, CONFIG_VERSION, UPGRADE_THRESHOLD); super(plugin, CONFIG_VERSION, UPGRADE_THRESHOLD);
@ -65,7 +64,10 @@ protected void doUpgrade(@NotNull YamlFileManager oldConfig)
{ {
Map<String, String> remappedKeys = new HashMap<>(); Map<String, String> remappedKeys = new HashMap<>();
if(oldConfig.getVersion() <= 23) remappedKeys.put("ItemFilter.Materials", "ItemFilter.Blacklist"); if(oldConfig.getVersion() <= 23) remappedKeys.put("ItemFilter.Materials", "ItemFilter.Blacklist");
doUpgrade(oldConfig, remappedKeys); if(oldConfig.getVersion() <= 28) remappedKeys.put("Misc.AutoUpdate.Enabled", "Misc.AutoUpdate");
Collection<String> keysToKeep = oldConfig.getYamlE().getKeysFiltered("Database\\.SQL\\.(MaxLifetime|IdleTimeout)");
keysToKeep.addAll(oldConfig.getYamlE().getKeysFiltered("Database\\.Tables\\.Fields\\..+"));
doUpgrade(oldConfig, remappedKeys, keysToKeep);
} }
} }
@ -186,15 +188,28 @@ public ShrinkApproach getShrinkApproach()
} }
} }
public boolean getAutoUpdate() //region Misc getters
public boolean useUpdater()
{ {
return getConfigE().getBoolean("Misc.AutoUpdate", true); return getConfigE().getBoolean("Misc.AutoUpdate.Enabled", getConfigE().getBoolean("Misc.AutoUpdate", true));
}
public String getUpdateChannel()
{
String channel = getConfigE().getString("Misc.AutoUpdate.Channel", "Release");
if("Release".equals(channel) || "Master".equals(channel) || "Dev".equals(channel))
{
return channel;
}
else logger.info("Unknown update Channel: " + channel);
return null;
} }
public boolean isBungeeCordModeEnabled() public boolean isBungeeCordModeEnabled()
{ {
return getConfigE().getBoolean("Misc.UseBungeeCord", false); return getConfigE().getBoolean("Misc.UseBungeeCord", false);
} }
//endregion
public long getCommandCooldown() public long getCommandCooldown()
{ {
@ -396,6 +411,10 @@ public int getItemShortcutPreferredSlotId()
return getConfigE().getInt("ItemShortcut.PreferredSlotId", -1); return getConfigE().getInt("ItemShortcut.PreferredSlotId", -1);
} }
public boolean getItemShortcutBlockItemFromMoving()
{
return getConfigE().getBoolean("ItemShortcut.BlockItemFromMoving", false);
}
public boolean isItemShortcutPlayerChoiceEnabled() public boolean isItemShortcutPlayerChoiceEnabled()
{ {
return getConfigE().getBoolean("ItemShortcut.AllowPlayersToChoseItem", true); return getConfigE().getBoolean("ItemShortcut.AllowPlayersToChoseItem", true);

View File

@ -84,7 +84,9 @@ public void close()
unCacheStrategie.close(); unCacheStrategie.close();
} }
public static Database getDatabase(Minepacks plugin) public static @Nullable Database getDatabase(Minepacks plugin)
{
try
{ {
String dbType = plugin.getConfiguration().getDatabaseType().toLowerCase(Locale.ROOT); String dbType = plugin.getConfiguration().getDatabaseType().toLowerCase(Locale.ROOT);
ConnectionProvider connectionProvider = null; ConnectionProvider connectionProvider = null;
@ -118,6 +120,13 @@ public static Database getDatabase(Minepacks plugin)
database.init(); database.init();
return database; return database;
} }
catch(IllegalStateException ignored) {}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}
public void backup(@NotNull Backpack backpack) public void backup(@NotNull Backpack backpack)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019 GeorgH93 * Copyright (C) 2020 GeorgH93
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,6 +28,7 @@
import org.intellij.lang.annotations.Language; import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.text.DateFormat; import java.text.DateFormat;
@ -59,7 +60,11 @@ protected ToSQLMigration(@NotNull Minepacks plugin, @NotNull Database oldDb, @No
switch(dbType) switch(dbType)
{ {
case "mysql": newDb = new MySQL(plugin, connectionProvider); break; case "mysql": newDb = new MySQL(plugin, connectionProvider); break;
case "sqlite": newDb = new SQLite(plugin, connectionProvider); break; case "sqlite":
final File dbFile = new File(SQLite.getDbFile(plugin));
if(dbFile.exists()) dbFile.renameTo(new File(SQLite.getDbFile(plugin) + ".old_" + System.currentTimeMillis()));
newDb = new SQLite(plugin, connectionProvider);
break;
default: newDb = null; default: newDb = null;
} }
} }

View File

@ -37,7 +37,7 @@
public abstract class SQL extends Database public abstract class SQL extends Database
{ {
private ConnectionProvider dataSource; private final ConnectionProvider dataSource;
protected String tablePlayers, tableBackpacks, tableCooldowns; // Table Names protected String tablePlayers, tableBackpacks, tableCooldowns; // Table Names
protected String fieldPlayerName, fieldPlayerID, fieldPlayerUUID, fieldBpOwner, fieldBpIts, fieldBpVersion, fieldBpLastUpdate, fieldCdPlayer, fieldCdTime; // Table Fields protected String fieldPlayerName, fieldPlayerID, fieldPlayerUUID, fieldBpOwner, fieldBpIts, fieldBpVersion, fieldBpLastUpdate, fieldCdPlayer, fieldCdTime; // Table Fields
@ -50,6 +50,7 @@ public SQL(@NotNull Minepacks plugin, @NotNull ConnectionProvider connectionProv
super(plugin); super(plugin);
dataSource = connectionProvider; dataSource = connectionProvider;
if(!dataSource.isAvailable()) throw new IllegalStateException("Failed to initialize database connection!");
loadSettings(); loadSettings();
buildQuerys(); buildQuerys();

View File

@ -33,10 +33,15 @@
public class SQLite extends SQL public class SQLite extends SQL
{ {
//TODO add cooldown sync table public static String getDbFile(final @NotNull Minepacks plugin)
public SQLite(@NotNull Minepacks plugin, @Nullable ConnectionProvider connectionProvider)
{ {
super(plugin, (connectionProvider == null) ? new SQLiteConnectionProvider(plugin.getLogger(), plugin.getDescription().getName(), plugin.getDataFolder().getAbsolutePath() + File.separator + "backpack.db") : connectionProvider); return plugin.getDataFolder().getAbsolutePath() + File.separator + "backpack.db";
}
//TODO add cooldown sync table
public SQLite(final @NotNull Minepacks plugin, final @Nullable ConnectionProvider connectionProvider)
{
super(plugin, (connectionProvider == null) ? new SQLiteConnectionProvider(plugin.getLogger(), plugin.getDescription().getName(), getDbFile(plugin)) : connectionProvider);
} }
@Override @Override

View File

@ -52,7 +52,7 @@ public class ItemShortcut implements Listener
private final Minepacks plugin; private final Minepacks plugin;
private final String openCommand; private final String openCommand;
private final Message messageDoNotRemoveItem; private final Message messageDoNotRemoveItem;
private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers; private final boolean improveDeathChestCompatibility, blockAsHat, allowRightClickOnContainers, blockItemFromMoving;
private final int preferredSlotId; private final int preferredSlotId;
private final Set<Material> containerMaterials = new HashSet<>(); private final Set<Material> containerMaterials = new HashSet<>();
private final ItemConfig itemConfig; private final ItemConfig itemConfig;
@ -64,6 +64,7 @@ public ItemShortcut(Minepacks plugin)
blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled(); blockAsHat = plugin.getConfiguration().isItemShortcutBlockAsHatEnabled();
allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed(); allowRightClickOnContainers = plugin.getConfiguration().isItemShortcutRightClickOnContainerAllowed();
preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId(); preferredSlotId = plugin.getConfiguration().getItemShortcutPreferredSlotId();
blockItemFromMoving = plugin.getConfiguration().getItemShortcutBlockItemFromMoving();
openCommand = plugin.getLanguage().getCommandAliases("Backpack", "backpack")[0] + ' ' + plugin.getLanguage().getCommandAliases("Open", "open")[0]; openCommand = plugin.getLanguage().getCommandAliases("Backpack", "backpack")[0] + ' ' + plugin.getLanguage().getCommandAliases("Open", "open")[0];
messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut"); messageDoNotRemoveItem = plugin.getLanguage().getMessage("Ingame.DontRemoveShortcut");
@ -135,21 +136,21 @@ public void onJoin(PlayerJoinEvent event)
addItem(event.getPlayer()); addItem(event.getPlayer());
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void onSpawn(PlayerRespawnEvent event) public void onSpawn(PlayerRespawnEvent event)
{ {
if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return; if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return;
addItem(event.getPlayer()); addItem(event.getPlayer());
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void onWorldChange(PlayerChangedWorldEvent event) public void onWorldChange(PlayerChangedWorldEvent event)
{ {
if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return; if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return;
addItem(event.getPlayer()); addItem(event.getPlayer());
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void onInventoryClear(InventoryClearedEvent event) public void onInventoryClear(InventoryClearedEvent event)
{ {
if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return; if(plugin.isDisabled(event.getPlayer()) != WorldBlacklistMode.None) return;
@ -272,6 +273,7 @@ else if(event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY)
event.setCancelled(true); event.setCancelled(true);
messageDoNotRemoveItem.send(player); messageDoNotRemoveItem.send(player);
} }
if(blockItemFromMoving) event.setCancelled(true);
} }
else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) && event.getHotbarButton() != -1) else if((event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.HOTBAR_SWAP) && event.getHotbarButton() != -1)
{ {

View File

@ -19,5 +19,4 @@
public class MagicValues public class MagicValues
{ {
public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.22-SNAPSHOT"; public static final String MIN_PCGF_PLUGIN_LIB_VERSION = "1.0.25-SNAPSHOT";}
}

View File

@ -18,8 +18,8 @@
package at.pcgamingfreaks.Minepacks.Bukkit; package at.pcgamingfreaks.Minepacks.Bukkit;
import at.pcgamingfreaks.Bukkit.MCVersion; import at.pcgamingfreaks.Bukkit.MCVersion;
import at.pcgamingfreaks.Bukkit.ManagedUpdater;
import at.pcgamingfreaks.Bukkit.Message.Message; import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Updater;
import at.pcgamingfreaks.Bukkit.Utils; import at.pcgamingfreaks.Bukkit.Utils;
import at.pcgamingfreaks.ConsoleColor; import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack; import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
@ -35,10 +35,8 @@
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.WorldBlacklistMode; import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.WorldBlacklistMode;
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Language; import at.pcgamingfreaks.Minepacks.Bukkit.Database.Language;
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.*; import at.pcgamingfreaks.Minepacks.Bukkit.Listener.*;
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.NoDatabaseWorker;
import at.pcgamingfreaks.StringUtils; import at.pcgamingfreaks.StringUtils;
import at.pcgamingfreaks.Updater.UpdateProviders.BukkitUpdateProvider;
import at.pcgamingfreaks.Updater.UpdateProviders.JenkinsUpdateProvider;
import at.pcgamingfreaks.Updater.UpdateProviders.UpdateProvider;
import at.pcgamingfreaks.Updater.UpdateResponseCallback; import at.pcgamingfreaks.Updater.UpdateResponseCallback;
import at.pcgamingfreaks.Version; import at.pcgamingfreaks.Version;
@ -61,11 +59,9 @@
public class Minepacks extends JavaPlugin implements MinepacksPlugin public class Minepacks extends JavaPlugin implements MinepacksPlugin
{ {
private static final int BUKKIT_PROJECT_ID = 83445;
@SuppressWarnings("unused")
private static final String JENKINS_URL = "https://ci.pcgamingfreaks.at", JENKINS_JOB_DEV = "Minepacks Dev", JENKINS_JOB_MASTER = "Minepacks";
private static Minepacks instance = null; private static Minepacks instance = null;
private ManagedUpdater updater = null;
private Config config; private Config config;
@Getter private BackpacksConfig backpacksConfig; @Getter private BackpacksConfig backpacksConfig;
private Language lang; private Language lang;
@ -119,6 +115,7 @@ public void onEnable()
} }
/*end[STANDALONE]*/ /*end[STANDALONE]*/
updater = new ManagedUpdater(this);
//region Check compatibility with used minecraft version //region Check compatibility with used minecraft version
if(MCVersion.is(MCVersion.UNKNOWN) || !MCVersion.isUUIDsSupportAvailable() || MCVersion.isNewerThan(MCVersion.MC_NMS_1_15_R1)) if(MCVersion.is(MCVersion.UNKNOWN) || !MCVersion.isUUIDsSupportAvailable() || MCVersion.isNewerThan(MCVersion.MC_NMS_1_15_R1))
@ -150,7 +147,7 @@ public void onEnable()
lang = new Language(this); lang = new Language(this);
load(); load();
if(config.getAutoUpdate()) update(null); if(config.useUpdater()) updater.update();
getLogger().info(StringUtils.getPluginEnabledMessage(getDescription().getName())); getLogger().info(StringUtils.getPluginEnabledMessage(getDescription().getName()));
} }
@ -158,36 +155,29 @@ public void onEnable()
public void onDisable() public void onDisable()
{ {
if(config == null) return; if(config == null) return;
Updater updater = null; if(config.useUpdater()) updater.update();
if(config.getAutoUpdate()) updater = update(null);
unload(); unload();
if(updater != null) updater.waitForAsyncOperation(); // Wait for updater to finish updater.waitForAsyncOperation(); // Wait for an update to finish
getLogger().info(StringUtils.getPluginDisabledMessage(getDescription().getName())); getLogger().info(StringUtils.getPluginDisabledMessage(getDescription().getName()));
instance = null; instance = null;
} }
public @Nullable Updater update(@Nullable UpdateResponseCallback updateResponseCallback) public void update(final @Nullable UpdateResponseCallback updateResponseCallback)
{ {
UpdateProvider updateProvider;
if(getDescription().getVersion().contains("Release")) updateProvider = new BukkitUpdateProvider(BUKKIT_PROJECT_ID, getLogger());
else
{
/*if[STANDALONE]
updateProvider = new JenkinsUpdateProvider(JENKINS_URL, JENKINS_JOB_MASTER, getLogger(), ".*-Standalone.*");
else[STANDALONE]*/
updateProvider = new JenkinsUpdateProvider(JENKINS_URL, JENKINS_JOB_DEV, getLogger());
/*end[STANDALONE]*/
}
Updater updater = new Updater(this, true, updateProvider);
updater.update(updateResponseCallback); updater.update(updateResponseCallback);
return updater;
} }
private void load() private void load()
{ {
updater.setChannel(config.getUpdateChannel());
lang.load(config); lang.load(config);
backpacksConfig.loadData(); backpacksConfig.loadData();
database = Database.getDatabase(this); database = Database.getDatabase(this);
if(database == null)
{
new NoDatabaseWorker(this);
return;
}
maxSize = config.getBackpackMaxSize(); maxSize = config.getBackpackMaxSize();
at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setShrinkApproach(config.getShrinkApproach()); at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setShrinkApproach(config.getShrinkApproach());
at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setTitle(config.getBPTitle(), config.getBPTitleOther()); at.pcgamingfreaks.Minepacks.Bukkit.Backpack.setTitle(config.getBPTitle(), config.getBPTitleOther());

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2020 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker;
import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Bukkit.Message.MessageBuilder;
import at.pcgamingfreaks.Bukkit.RegisterablePluginCommand;
import at.pcgamingfreaks.Message.MessageColor;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
import at.pcgamingfreaks.Minepacks.Bukkit.Permissions;
import at.pcgamingfreaks.Reflection;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* This worker will inform the admin that the plugin failed to connect to the database, he hopefully is able to solve the problem.
* It registers a new command that only allows to reload the plugin to prevent unnecessary downtime for the server cause of restarts.
*/
public class NoDatabaseWorker extends SpecialInfoBase implements CommandExecutor
{
private final Minepacks plugin;
private final RegisterablePluginCommand command;
private final Message messageDBProblem;
public NoDatabaseWorker(final @NotNull Minepacks plugin)
{
super(plugin, Permissions.RELOAD);
this.plugin = plugin;
Bukkit.getPluginManager().registerEvents(this, plugin);
command = new RegisterablePluginCommand(plugin, "backpack");
command.registerCommand();
command.setExecutor(this);
messageDBProblem = new MessageBuilder("Minepacks", MessageColor.GOLD).append(" failed to connect to its database!", MessageColor.RED).appendNewLine()
.append("Please check your configuration and reload the plugin (", MessageColor.RED).append("/backpack reload", MessageColor.BLUE).command("/backpack reload").append(")!", MessageColor.RED).getMessage();
}
@Override
protected void sendMessage(Player player)
{
messageDBProblem.send(player);
}
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command cmd, @NotNull String s, String[] strings)
{
if(strings.length != 1 || !strings[0].equalsIgnoreCase("reload"))
{
commandSender.sendMessage(MessageColor.RED + "Only \"/backpack reload\" is available at the moment!");
}
else
{
if(commandSender.hasPermission(Permissions.RELOAD))
{
command.unregisterCommand();
HandlerList.unregisterAll(this);
try
{
plugin.getConfiguration().reload();
Reflection.getMethod(plugin.getClass(), "load").invoke(plugin);
}
catch(Exception e)
{
e.printStackTrace();
}
}
else
{
commandSender.sendMessage(MessageColor.RED + "You don't have the permission to do that!");
}
}
return true;
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2020 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class SpecialInfoBase implements Listener
{
private final JavaPlugin plugin;
private final String permission;
protected SpecialInfoBase(final JavaPlugin plugin, final String permission)
{
this.plugin = plugin;
this.permission = permission;
}
@EventHandler
public void onJoin(final PlayerJoinEvent event)
{
if(event.getPlayer().hasPermission(permission))
{
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if(event.getPlayer().isOnline())
{
sendMessage(event.getPlayer());
}
}, 3 * 20L); // Run with a 3 seconds delay
}
}
protected abstract void sendMessage(final Player player);
}

View File

@ -7,8 +7,7 @@
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<revision>2.4-ALPHA-SNAPSHOT</revision> <revision>2.4-ALPHA-SNAPSHOT</revision> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>