1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 17:53:00 +01:00

Compare commits

..

16 Commits

Author SHA1 Message Date
T00thpick1
b700a99c52 NuclearW loves his spacing, also pinging him. 2013-03-11 00:12:31 -04:00
T00thpick1
7294175d9c Messages 2013-03-11 00:08:18 -04:00
NuclearW
1b17b90f32 Diff cleanup 2013-03-10 22:54:47 -04:00
NuclearW
d27f668a2e Fix rebase (see also: me) being dumb 2013-03-10 22:30:20 -04:00
T00thpick1
69dd5769e4 Correct format and comment 2013-03-10 22:30:20 -04:00
T00thpick1
7c9d09a878 Clean queuemanager on disable 2013-03-10 22:30:20 -04:00
T00thpick1
17c64251db Position right 2013-03-10 22:30:19 -04:00
T00thpick1
d728eba5c4 Change not addition 2013-03-10 22:30:19 -04:00
T00thpick1
429055bae2 Update changelog 2013-03-10 22:30:19 -04:00
T00thpick1
3f22a8f479 The sleep didn't actually do much of anything.... 2013-03-10 22:30:19 -04:00
T00thpick1
aeae60f968 check permissions earlier 2013-03-10 22:30:19 -04:00
T00thpick1
a97b889af5 Queue 2013-03-10 22:30:18 -04:00
T00thpick1
0e9953c25b Throttle 2013-03-10 22:30:18 -04:00
T00thpick1
869b30fcaa String wrapper 2013-03-10 22:30:18 -04:00
T00thpick1
44188396b4 One per player 2013-03-10 22:30:18 -04:00
T00thpick1
a7f146a835 queue concept, nowhere near final 2013-03-10 22:30:18 -04:00
1057 changed files with 35029 additions and 73866 deletions

344
.gitignore vendored
View File

@@ -1,330 +1,42 @@
# Eclipse stuff
/.classpath
/.project
/.settings
### Eclipse template
# netbeans
/nbproject
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
# we use maven!
/build.xml
# External tool builders
.externalToolBuilders/
# maven
/target
# Locally stored "Eclipse launch configurations"
*.launch
# vim
.*.sw[a-p]
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# various other potential build files
/build
/bin
/dist
/manifest.mf
# CDT-specific (C/C++ Development Tooling)
.cproject
/world
# CDT- autotools
.autotools
# Mac filesystem dust
*.DS_Store
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Android template
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
# intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
### Dropbox template
# Dropbox settings and caches
.dropbox
.dropbox.attr
.dropbox.cache
### Windows template
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### NetBeans template
nbproject/private/
nbbuild/
dist/
nbdist/
.nb-gradle/
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Linux template
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### GPG template
secring.*
### Gradle template
.gradle
/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
### SBT template
# Simple Build Tool
# http://www.scala-sbt.org/release/docs/Getting-Started/Directories.html#configuring-version-control
dist/*
lib_managed/
src_managed/
project/boot/
project/plugins/project/
.history
.cache
.lib/
### Example user template template
### Example user template
# IntelliJ project files
.idea
out
gen### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.ipr
*.iws
.idea/
# IntelliJ
# mpeltonen/sbt-idea plugin
.idea_modules/
# Project Stuff
/src/main/resources/mcMMO
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Kotlin template
# Compiled class file
# Log file
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
# Other Libraries
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Java template
# Compiled class file
# Log file
# BlueJ files
# Mobile Tools for Java (J2ME)
# Package Files #
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
# Atlassian Stuff
/atlassian-ide-plugin.xml

View File

@@ -7,657 +7,10 @@ Key:
! Change
- Removal
Version 2.2.0
mcMMO has a new config system (WIP)
mcMMO for Bukkit no longer requires Spigot in order to play, you can now use Bukkit instead (WIP)
mcMMO is now abstracted from the Bukkit API in order to support more platforms (WIP)
mcMMO has changed from using maven to gradle!
mcMMO is now a gradle project (this makes it much easier for us to support older versions of MC and other APIs)
Version 2.1.12
Salvage config entries are no longer case sensitive
Fixed a bug where Fishing was not rewarding vanilla XP orbs
Version 2.1.11
Fixed a bug where Rupture was using the wrong permission node (new permission node: mcmmo.ability.swords.rupture)
Version 2.1.10
Fishing command did an oopsie
Endstone now gives the same XP as Stone (update your experience.yml)
Version 2.1.9
Fixed a bug where grabbing the version of WG would throw classnotdefined errors
Version 2.1.8
mcMMO now checks for WG 7 before attempting to use the WG API
Made some optimizations for our WG integration
Fixed a bug where Bite chance for Master Angler was displaying too many decimal places
Fixed a bug where Abilities didn't check for permission nodes before activating
MaxBonusLevel now has specific entries for Standard and Retro in advanced.yml
MaxBonusLevel for Critical Strikes changed from 75/750 to 100/1000
MaxBonusLevel of Dodge changed from 80/800 to 100/1000
MaxBonusLevel of Rupture changed from 20/200 to 100/1000
MaxBonusLevel of Counter Attack changed from 60/600 to 100/1000
Version 2.1.7
Fixed an almost 6 year old bug where Salvage materials did not have a defined material count so they defaulted to 2 (which could lead to shovels giving back more diamonds than normal)
Added spam detection for Unarmed's bonus damage and disarm
Corrected an error where master angler for retro only required level 150 instead of 500 (update your skillranks.yml)
Fixed a bug where Players could see hidden party members in the party member listings
(API) Added addXpFromBlocks to ExperienceAPI to help make adding XP for a player easier
(API) Added addXpFromBlocksBySkill to ExperienceAPI to help make adding XP for a player easier
(API) Added addXpFromBlock to ExperienceAPI to help make adding XP for a player easier
(API) Added addXpFromBlockBySkill to ExperienceAPI to help make adding XP for a player easier
Version 2.1.6
Fixed a bug where Arcane Salvage could never fail
Recolored some lines in the locale related to failure from white to red
Fixed a bug where Salvage was giving back too many resources
SubSkillFailure renamed to SubSkillFailed in config.yml
SubSkillFailed now sends copies to chat by default
SubSkillFailed no longer sends messages to the action bar by default
Version 2.1.5
mcMMO no longer ignores cancelled events relating to the player left or right clicking
Version 2.1.4
Fixed a bug where Alchemy didn't gain XP
Fixed a bug where Archery gained XP from mob spawned entities
Fixed a display bug with Roll on /acrobatics command
Fixed a display bug for bite chance on Fishing
Fixed a display bug for treasure drop chances on Fishing
Fixed a display bug for Arcane Forging on Repair
Fixed a display bug for Super Repair on Repair
Fixed a display bug for Repair Mastery on Repair
Fixed a display bug for Second Smelt on Smelting
Repair Mastery now uses a rank system
Super Repair now uses a rank system
Changed the stat for bite chance to be more clear that its additive chance
Fixed Styling for the /salvage command
Temporarily disabled Flux Mining
Removed XP from entities that target endermite to prevent easy exploitation (Credits to TheBentoBox for the tip!) [Can be turned off in experience.yml]
Fixed a bug where static chance skills like Arcane Salvage were using incorrect calculations for success
Advanced Salvage now uses a rank system
Arcane Salvage now goes by your rank to determine the maximum amount of materials salvaged and is no longer percentage based
Fixed a bug where Iron Arm was checking for Iron Grip to be unlocked instead of itself
(Plugin Compatibility) mcMMO no longer ignores cancelled block place events (this is to prevent XP gains from placed blocks)
(Plugin Compatibility) mcMMO now ignores cancelled events relating to the player left or right clicking
(Locale) Changed the string for "Salvage.Ability.Bonus.1" to fit the new material recovery mechanics of Salvage
(Config) Added a toggle for the new endermite enderman xp farm fix in experience.yml "ExploitFix.EndermanEndermiteFarms"
(Config) Cleaned up some leftover 'unlocklevel' settings, this stuff is now handled in skillranks.yml
(Config) Removed Salvage.MaxPercentage
(Config) Removed Salvage.MaxPercentageChance
(Config) Added Salvage.ArcaneSalvage.MaxBonusLevel
(Config) Added Salvage.ArcaneSalvage.MaxChance
Version 2.1.3
Temporarily removed the unarmed no-item pickup feature until its fixed
Version 2.1.2
(Compatibility) mcMMO now deals custom damage type for all damage sources to be more compatible with other plugins (such as anti-cheat)
(Perks) Fixed a bug where the Lucky perk wasn't adding to success
(Skills) mcMMO will now listen to cancelled events to remove our temporary enchantments from tools
(Skills) Fixing a bug where Shake didn't calculate success correctly
(Skills) Fixed a bug where Arcane Forging didn't calculate success and failure correctly
(Skills) Fixed a bug where Salvage didn't calculate success and failure correctly
(Skills) Fixed a bug where Flux Mining didn't calculate success correctly
(Skills) Fixed a bug where Shake didn't calculate correctly
(Skills) Fixed a bug where Pummel didn't calculate correctly
(Skills) Tree Feller now works on Mushroom Stems
(Skills) Fixed a bug where magic chance would show as null
(Skills) Fixed a bug where Trap percentages were added to Fishing even though they no longer exist
(Skills) Magic Hunter now uses a rank system
(Skills) Fixed a bug where Magic Hunter would work without treasure hunter
(Skills) As long are you are empty handed mcMMO will no longer put items into your hands
(Skills) Improved the styling on /smelting
(Skills) Iron Arm Style can now reach a bonus damage of 10 (up from 8)
(Skills) Iron Arm Style now uses a rank system
(Skills) Iron Grip now uses a rank system
(Skills) Disarm now uses a rank system
(Skills) Arrow Deflect now uses a rank system
(Skills) Flux Mining is now a passive effect when you mine ore instead of requiring a special pickaxe
(Skills) Removed the Flux Mining mcMMO Pickaxe Item
(Style) Locked skills now are styled differently in the skill command display
(Experience) Phantoms have been added to the default experience.yml with a value of 4.0 (update your config!)
(Experience) Default XP value for witch set to 0.1 instead of 0.0
(Experience) Default XP value for ender dragon set to 1.0 instead of 0.0
(Style) Added @ symbol styling for hover tooltips to the locale
(Style) Added the skill names in the skill commands display to the locale so it can now be edited and styled
(Experience) Renamed Grass to Grass_Block in treasures.yml to allow grass to give items again (update your configs manually or delete to regen)
(Experience) Wood blocks now give XP and are affected by Tree Feller (6 sided bark blocks)
(API) Moved XPGainReason from skills to experience package
(API) Added XpGainSource for tracking sources of XP
(API) You can now specify XpGainSource when adding xp to players
(Config) The Extra Stats option for XP bars now overrides the setting for updating XP bars every time XP is gained
(Config) Added an option for Party XP gains to not update XP bars
(Config) Added an option for Passive XP gains to not update XP bars (smelting/brewing)
(Config) Added warnings if mcMMO finds a MaxBonusLevel of 0 for any skill that incorporates RNG
(Config) Removed config options for Iron Arm
(Config) Removed the options related to the Flux Mining Item
(Config) Second Smelt has a max activation chance of 50% instead of 100% (you can update your configs or gen new ones to get this change)
Version 2.1.1
= Fixed an issue where excavation wasn't using the correct permission node
= Added protection against AFK fishing
= Acrobatics now uses much better anti-exploit detection
Version 2.1.0
+ mcMMO now features XP bars! Configurable in experience.yml
+ Locale files now support & codes for colors and formatting!
+ Prevented exploits involving blocks made from entities (snowmen, etc..)
+ Added JSON integration to all Skill Commands
+ Added config setting to enable or disable old mcMMO skill scaling (General.RetroMode) this is on by default for existing installs
+ You can now disable specific skills in coreskills.yml without the need for permissions
+ Added links to mcMMO related websites to various commands
+ Certain elements of mcMMO's UI have been restyled
+ Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
+ You can now disable mcMMO completely for specific worlds via world_blacklist.txt in /plugins/mcMMO/
+ (WorldGuard) mcMMO now supports worldguard, you can use the flags "mcmmo" and "mcmmo-xp" on regions (they default to on unless otherwise specified)
! (Scoreboards) Scoreboards are now disabled by default, I don't like them. You can turn them back on in config.yml
+ (Sounds) Rolling now plays a sound (Graceful Roll has a different sound :) )
+ (Sounds) Activating Super abilities plays a sound (other plays can hear this)
+ (Sounds) Skill Unlock Notifications have sounds
+ (Sounds) Readying a tool for a super ability now plays a sound
+ (Sounds) Bleed DOT now plays a sound
+ (Experience) mcMMO now notifies you when you progress in a skill!
+ (Experience) Coral (blocks) now give Mining XP
+ (Experience) Coral (plants) now give Herbalism XP
+ (Experience) Blue Ice now gives Mining XP
+ (Experience) Dolphins now give combat XP
+ (Experience) Drowned mobs now count towards combat XP
+ (Experience) You can now set guaranteed minimum values for XP gained if diminishing returns are enabled, this value defaults to 5% (experience.yml)
+ (Events) Starting an XP event will now use the title API (toggle this in advanced.yml)
+ (Sound) Volume and Pitch of sounds can now be configured in the new sounds.yml file
+ (MySQL) Added support for SSL for MySQL/MariaDB (On by default)
! (Skills) Taming's Gore now uses Rupture Rank 1 for its DoT calculations
! (Skills) Sword's Bleed has been renamed to Rupture
! (Skills) Sword's Rupture no longer has an internal hard coded limit
! (Skills) Sword's Serrated Strikes now uses your Rupture rank to determine the damage/ticks for its bleed effect.
! (Skills) Sword's Rupture now ticks four times as fast
! (Skills) Sword's Rupture now refreshes bleed duration instead of adding duration when applying bleed to the same target
! (Skills) Sword's Rupture will now deal lethal damage
= (Skills) Fixed a bug where Rupture would apply an incorrect amount of bleed ticks
! (Skills) Sword's Rupture now reaches its max proc chance at level 20 (200 in Retro)
! (Skills) Sword's Rupture now has a max chance to proc of 33% instead of 70%
! (Skills) Sword's Rupture now deals 50% more damage at above Rank 3 and can last much longer! The base damage for Bleed has been increased as well (update your advanced.yml admins)
! (Skills) Sword's Rupture no longer triggers invincibility frames when damaging your opponent
= (Skills) Furnaces now give XP to the last person to modify their inventory instead of the first person to open them
+ (Skills) Ability Lengths now have a default skill cap at which they stop increasing in length, configurable in advanced.yml (endurance perks extend this limit)
+ (Skills) Added a new subskill to some skills 'Understanding The Art' this adds nothing new, but tracks benefits that increase together that seemed unrelated, which was previously a bit obfuscated.
+ (Skills) Tool alerts now are sent to the Action Bar
+ (Skills) Super Ability activation alerts are now sent to the Action Bar
+ (Skills) Certain Skill messages are now sent to the Action Bar
+ (Skills) Added some missing information to skill stats
+ (Config) Skill Rank requirements are now defined in skillranks.yml you cannot add or remove ranks from this file
+ (Config) Added option to use SSL for MySQL in config.yml
+ (Config) Added option to disable the new URL links to config.yml
+ (Config) New config file added coreskills.yml
+ (Config) Added rank settings for the new Woodcutting skill
+ (Config) Added configurable parameters for the new Tree Feller
+ (Config) Added retro toggle for Tree Feller
+ (Config) Added toggle to disable all scoreboards
+ (Chat) Added ability for admins to spy on party chat (off unless toggled on)
+ (Commands) Added new info command /mmoinfo or /mcinfo
+ (Commands) Added toggle command /mcchatspy
+ (API) Added many missing SubSkills to SubSkillType class
+ (Permissions) Added permission node mcmmo.commands.mcchatspy & mcmmo.commands.mcchatspy.others
+ (Permissions) Added permission nodes for Harvest Lumber, Splinter, Nature's Bounty, and Bark Surgeon
+ (Permissions) Added mcmmo.commands.mmoinfo for the new mmoinfo/mcinfo command
! (Permissions) Call of the wild now uses mcmmo.ability.taming.callofthewild instead of mcmmo.ability.taming.callofthewild.all
+ (Locale) Added locale strings for new Woodcutting abilities
+ (Locale) Added locale strings for mcchatspy command
+ (Locale) Added locale strings for JSON integration
+ (Locale) Added locale strings for Taming's Pummel SubSkill
+ (Locale) Added locale strings for Unarmed's Block Cracker SubSkill
- (Locale) Removed localizations with the following codes for being almost empty: id, HR_hr, et_EE, lv, lt, no, pl_PL, pt_PT, tr_TR
- (Config) Removed SkillShot's IncreaseLevel & IncreasePercentage (replaced by RankDamageMultiplier)
- (Config) Removed AxeMastery's MaxBonus & MaxBonusLevel (replaced by RankDamageMultiplier)
= (Events) Fixed bug where XP rate could be a negative number
= (Experience) Fixed a bug where you could set a players levels into the negative and bad things would happen
= (Plugin Compatibility) mcMMO now fires new custom events relating to changes it makes to player scoreboards, plugin authors can listen to these events to improve compatibility
= (Items) Chimaera Wing now tracks cooldowns between sessions for players (no more disconnect abuse)
= (Skills) Added missing mushroom blocks to experience.yml defaults
= (Skills) Tridents will no longer be considered unarmed
= (MySQL) You can now inspect offline players
= (MySQL) When converting from MySQL to flatfile mcMMO will now properly include all users in the conversion process
= (Commands) '/mcMMO help' no longer displays the other/special commands category to players lacking permissions
+ (Party) Parties can now have size limits (configurable in config.yml), party size is unlimited by default
+ (Party) You can now turn on Friendly Fire for parties in config.yml
+ (Debug Stick) The Debug stick can now tell you about properties of a block related to Excavation
! (Deaths) Fixed the bug where mob names would be replaced by hearts
! (Experience) The XP values of fish are now based on their rarity and have been drastically changed
! (Experience) Skills now start at level 1 (configurable in advanced.yml)
! (Item) Improved some of the messages sent to the player regarding the Chimaera Wing
! (Party) Party member list will only include members of the party that you can see (aren't vanished)
! (Skills) Excavation Treasure Hunter is renamed to Archaeology
! (Skills) Swords no longer require blocking with a shield to trigger counter attacks
! (Skills) Stripping wood and right clicking on stripped wood will no longer ready your Axe
! (Skills) Some skill level rank requirements have changed
! (Skills) Green Thumb now uses a rank system
! (Skills) Farmer's Diet & Fisherman's Diet now use a rank system
! (Skills) Fixed an edge case bug where Blast Mining wouldn't inform the player that it was on cooldown
! (Skills) mcMMO skills will now be on a scale from 1-100 instead of 0-1000 (for existing mcMMO installs this is opt-in and off by default)
! (Skills) Skill Super Powers now use a rank system, almost all of them unlocking first at level 10
! (Skills) Acrobatics' Roll exploit detection was tweaked to still allow for Roll to trigger even if it rewards no XP
! (Skills) Acrobatics' Roll & Gracefull Roll are now considered the same skill (both mechanics are still there)
! (Skills) Woodcutting's Double Drop subskill is now named Harvest Lumber
! (Skills) Archery's Skill Shot now uses a rank system
! (Skills) Swords' Bleed now uses a rank system
! (Skills) Swords' Counter Attack now uses a rank system
! (Skills) Axe's Axe Mastery now uses a rank system
! (Skills) Axe's Impact now uses a rank system
! (Skills) Herbalism's Farmer's Diet now uses a rank system
! (Skills) Herbalism's Green Thumb now uses a rank system
! (Skills) Shake now uses a rank system
! (Skills) Flux Mining now uses a rank system
! (Skills) Removed traps from fishing
! (Skills) Dodge now uses a rank system
! (Skills) Arrow Retrieval now uses a rank system
! (Skills) Axes' Critical Strikes now uses a rank system
! (Skills) Axes' Greater Impact now uses a rank system
! (Skills) Taming's Beast Lore now uses a rank system
! (Skills) Taming's Gore now uses a rank system
! (Skills) Taming's Call of the Wild now uses a rank system
! (Skills) Taming's Pummel now uses a rank system
! (Kraken) Removed everything involving the kraken
= (Skills) Shake now sends custom damage types for better nocheat compat
! (Config) Unarmed.IronArm in advanced.yml is now Unarmed.IronArmStyle
! (Config) Unarmed.Deflect in advanced.yml is now Unarmed.ArrowDeflect
! (Config) Swords.Counter in advanced.yml is now Swords.CounterAttack
! (Config) Archery.Retrieve in advanced.yml is now Archery.ArrowRetrieval
! (Config) Axes.CriticalHit in advanced.yml is now Axes.CriticalStrikes
! (Config) Archery's Skill Shot now uses RankDamageMultiplier for its damage bonus calculations
! (Config) Axe's Axe mastery now uses RankDamageMultiplier for its damage bonus calculations
! (Permissions) Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node
! (Permissions) Fast Food Service permission node renamed to mcmmo.ability.taming.fastfoodservice
! (Permissions) Counter Attack permission node renamed to mcmmo.ability.swords.counterattack
! (Permissions) Arrow Deflect permission node renamed to mcmmo.ability.unarmed.arrowdeflect
! (Permissions) Iron Arm Style permission node renamed to mcmmo.ability.unarmed.ironarmstyle
! (Permissions) Remove all mob health bar permissions, this is no longer a per-player setting.
! (Commands) Removed the mobhealthbar command, this is no longer a per-player setting.
! (Locale) The descriptions of a few skills have changed
! (Locale) Removed redundant information from some skill names and descriptions en_US (other locales will need to be updated)
! (Locale) SubSkill locale keys are now located at {ParentSkill}.SubSkill.SubSkillName
! (Locale) Super Abilities no longer have (ABILITY) in their Skill.Effect strings
! (API) mcMMO is now built against Spigot-API instead of Bukkit
! (API) Moved a lot of methods from SkillCommand to SkillUtils
! (API) SkillType is now PrimarySkillType
! (API) SecondarySkill is now SubSkillType
! (API) AbilityType is now SuperAbilityType
! (API) SecondaryAbilityEvent is now SubSkillEvent
! (API) SubSkillType has had many helpful methods added to it
! (API) GREEN_THUMB_PLANT & GREEN_THUMB_BLOCK are replaced by GREEN_THUMB
! (Code) Refactored some unreadable code relating to SecondaryAbilityType activation in SkillUtils
Version 2.0.0
= Fixed an interaction between Tree Feller and Stripped Wood
! Fireworks no longer fire by default for ability activation/deactivation
! Website has been changed and the MOTD string relating to it reflects this
! Discord link added to mcMMO command
! Updated misc strings relating to mcMMO
Version 1.5.05-SNAPSHOT
Version 1.5.04
+ Added option to config.yml to control mcMMO generated sound volume
+ Added option to config.yml to truncate existing player skill levels that exceed the skill level cap
+ Falling blocks persist mcMMO natural data
= Woodcutting double drops correctly identify acacia and dark oak logs
= Skill Reset command now correctly identifies arguments
= Hylian Treasure config options are now actually used
= Child skills now use parent skills configured skill caps properly
= Auto Update config now properly works
! Item dropped from blocks now drop from the center
! Potions Config updated for 1.9
! Flux mining now simulates a block break event for other plugins to act upon
! Zombie Pigmen spawned from nether portals are now considered spawner mobs
! Flux Pickaxe lore now appends to existing lore as opposed to replacing it
! Party chat no longer displays colors when logged in server console
- Treefeller no longer lowers exp for big trees
- No longer supports 1.8 :(
- Removed plugin metrics
Version 1.5.03
= Fixed bug where absorption hearts could be attacked by allied players
= Fixed bug where new forms of stone would drop the wrong type when mined with Silk Touch
= Fixed bug where blocks would not get tracked correctly when using sticky pistons and slime blocks in certain situations
= Fixed bug where config value for Daze damage was ignored
= Fixed UUID updater to not lose data on errors
= Fixed bug where uuid update could result in large amounts of user data being deleted
= Fixed bug where custom potions were missed in potion stage calculation
= Fixed piston dupe bugs permanently
= Fixed bug involving user name changes
= Fixed old user purge to properly calculate months
= Fixed bug where Repair would incorrectly check items
= Fixed bug where apostrophes in locale files would not read correctly
= Fixed bug where treasure data was limited to 255 instead of Short.MAX_VALUE
! Moved more user loading calculations to async loading thread to reduce lag on login
Version 1.5.02
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points
+ Added option to config.yml to let non-tools in hand count as unarmed
+ Added option to experience.yml to control XP gained by killing bred animals
+ Added support for 1.8 mobs and features
= Fixed bug where no Mining XP was granted when Flux Mining was successful
= Fixed bug with UUID conversions in Flatfile
= Fixed a couple Dupe bugs that were introduced recently
= Fixed bug where MobHealthbarTypes were not saved between server restarts
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
! Changed Archery distance multiplier to be configurable
! Archery distance XP bonus cannot exceed indefinitely anymore
Version 1.5.01
+ Added new child skill; Salvage
+ Added UUID support!
+ Added SQL connection pooling and async loading!
+ Added the long awaited Diminished Returns feature
+ Added new feature to Herbalism. Instantly-regrown crops are protected from being broken for 1 second
+ Added option to config.yml to show the /mcstats scoreboard automatically after logging in
+ Added option to config.yml for Alchemy. Skills.Alchemy.Prevent_Hopper_Transfer_Bottles
+ Added option to config.yml for Scoreboards, display "Ability" instead of ability names on the scoreboards
+ Added options to experience.yml for Dirt and Sand variations
+ Added support for `MATERIAL|data` format in treasures.yml
+ Added API to experience events to get XP gain reason
+ Added API to check if an entity is bleeding
+ Added API to ExperienceAPI to get the amount of XP needed for a level
+ Added API class SkillAPI used to get a list of valid skill names
+ Added API events for hardcore features, McMMOPlayerPreDeathPenaltyEvent, McMMOPlayerStatLossEvent and McMMOPlayerVampirismEvent
+ Added API to ExperienceAPI to specify if XP can be shared
+ Added options to tools.yml and armor.yml config files to set a pretty repair material name
+ Added full support for repairables in tools.yml and armor.yml config files
+ Added magical mod config file import command, for Cauldron 1.7+. Check wiki for usage
+ Added particle effects and sounds to "Call of the Wild" (Taming)
+ Added summon length to "Call of the Wild". Summons will now commit suicide after their lifespan expires
+ Added feature which makes tamed wolves attack a target shot by the owner
= Fixed bug where pistons would mess with the block tracking
= Fixed bug where the Updater was running on the main thread.
= Fixed bug when players would use /ptp without being in a party
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
= Fixed bug where dodge would check the wrong player skill level
= Fixed bug which causes /party teleport to stop working
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
= Fixed bug where Alchemy would not fire BrewEvents
= Fixed bug with setting custom names and lore in treasures config
= Fixed bug which would cause a NullPointerException with getFlowerAndGrassXp()
= Fixed bug which could cause and SQLException regarding the connection property 'maxReconnects'.
= Fixed bug where falling blocks were incorrectly tracked
= Fixed bug where items would get deleted when in Berserk with a full inventory
= Fixed bug where the console would not correctly show party chat colors
= Fixed bug where party chat was using non thread safe methods
= Fixed bug where Blast Mining unlock levels could be to high in certain occasions
= Fixed bug where Blast Minings ability "Demolition Expert" would not work
= Fixed bug where Repair_Material_Quantity wasn't read in mod config files
! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
! Changed the way mcMMO handles bonus damage, updated for the new damage event API
! Changed player data saving. Save tasks are now asynchronous
! Vanished players no longer get hit by AoE effects
! Changed Alchemy config option 'Prevent_Hopper_Transfer' renamed to 'Prevent_Hopper_Transfer_Ingredients'
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
! Changed behavior of the Blast Mining ability "Demolition Expert"; now only decreases damage for the ability user
! Updated for new getOnlinePlayers() behavior
! Updated for new blocks and entities
! Changed McMMOPlayerDeathPenaltyEvent to get fired after hardcore penalty calculations, use McMMOPlayerPreDeathPenaltyEvent for old behavior
! Moved Refresh_Chunks setting from hidden.yml to config.yml
- Removed salvage ability from Repair, salvage has it's own (child) skill now
Version 1.5.00
+ Added Podzol & Red Sand to Excavation
+ Added Hardened Clay, Stained Clay, and Packed Ice to Mining blocks
+ Added Acacia and Dark Oak to Woodcutting blocks
+ Added Salmon, Clownfish, and Pufferfish to Fishing XP
+ Added new flowers and grasses to Herbalism XP
+ Added option to config.yml which allows players to always catch fish, even when a treasure is found
+ Added option to config.yml to override vanilla Minecraft treasures
! Fishing XP now depends on the type of fish.
! Woodcutting XP in experience.yml and Woodcutting double drops in config.yml now use the tree species names. Oak is now Generic, and Spruce is now Redwood.
! Red_Rose was replaced by Poppy, and so the key in experience.yml has been updated accordingly.
- Removed deprecated permission nodes
- Removed "Treasure found!" message
Version 1.4.08
+ Added a new skill; Alchemy. Special thanks to EasyMFnE for creating this!
+ Added SecondaryAbilityType enum, and new SecondaryAbilityWeightedActivationCheckEvent, fired when a secondary ability checkes its activation chances
+ Added the possibility to gain experience when using Fishing "Shake"
+ Added config options to disable various sound effects
+ Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP.
+ Added automatic cleanup of backups folder.
+ Added bypass permission for finding Fishing traps
+ Added level threshold settings to hardcore modes. When a players skill level is below this threshold, they will not lose any stats
+ Added party alliances, two parties can now team up. Allies share party chat and cannot harm each other.
+ Added new experience bonus perk 'mcmmo.perks.xp.10percentboost.<skillname>' multiplies incoming XP by 1.1
+ Added new experience bonus perk 'mcmmo.perks.xp.customboost.<skillname>' multiplies incoming XP by the boost amount defined in the experience config
+ Added Ender Dragon, Wither, and Witch to combat experience multipliers - they do not give XP by default
+ Added support for multiple mod config files, naming can be done as either armor.<modname>.yml or <modname>.armor.yml
+ Added config options to configure the items used in "Call of the Wild"
+ Added config option to configure the database command cooldown
= Fixed bug where healthbars wouldn't display if skills were disabled
= Fixed bug with "Call of the Wild" entities despawning
= Fixed bug with updating (very) old user data.
= Fixed bug with checking maximum durability of mod items.
= Fixed exploit involving Call of The Wild.
= Fixed bug where LeafBlower permissions were ignored
= Fixed bug with toggle commands not properly displaying the success message.
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
= Fixed bug with Salvage not reading the config value for the anvil material.
= Fixed exploit where you could receive smelting XP for improper items
= Fixed bug where the Unbreaking enchantment was ignored when using "Super Breaker" or "Giga Drill Breaker"
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
= Fixed bug where cooldown donor perks were reducing more than expected
= Fixed bug where disabling hardcore mode for specific skills didn't work
= Fixed bug which caused the net.shatteredlands.shatt.backup cleanup to delete old backups while it should have kept those
= Fixed bug where party chat broke if the display name contained special characters
= Fixed bug where `/addlevels all` and `/skillreset all` didn't work
= Fixed bug which made it possible to gain XP by taming the same horse multiple times, if a player "untamed" that horse
= Fixed bug where some horses summoned with "Call of the Wild" were unable to jump
= Fixed bug where the /ptp request expiration time was checked wrongly - preventing players from using the command
= Fixed bug where Hylian Luck was broken
= Fixed bug where Snow would never drop treasures
= Fixed issues with commands giving away vanished players.
= Fixed bug where the Repair lucky perk would increase the Arcane Forging downgrade chance, instead of decreasing it
! Changed party system. Parties now have XP and Levels. Party features such as party teleport and party chat have to be unlocked before they can be used by the party members
! Changed appearance of party member list. Gold = party leader, White = online, Gray = offline, Italic = not nearby
! Updated localization files
! Changed the appearance of /mcmmo commands
! Changed AxesCritical to CriticalHit in config file
! Changed several secondary ability permissions(deprecated versions still exist)
! Changed /ptp config setting, Commands.ptp.Confirm_Required is now Commands.ptp.Accept.Required
! Changed config validation for UnlockLevels, they can now also be 0
! Changed config validation for Rank_Levels, successive Ranks can now be less than or equal to each other
! Changed default amount of XP gained from mining Quartz Ore. From 250 to 100 XP.
! Changed Acrobatics config setting, Skills.Acrobatics.Prevent_XP_After_Teleport is now Skills.Acrobatics.XP_After_Teleport_Cooldown
- Removed /stats alias for /mcstats
Version 1.4.07
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
+ Added more tiers to Fishing, Repair and Smelting!
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
+ Added horses to the "Shake" ability
+ Added ability to summon horses via "Call of the Wild" using apples
+ Added XP gain to Taming for horses
+ Added new permission nodes to allow more control over Taming and "Call of the Wild"
+ Added new experience.yml config file! Moved all experience related settings from config.yml to experience.yml
+ Added support for EXPONENTIAL formula curves to experience.yml
+ Added new /mcconvert command to convert players levels and experience from one formula curve to another.
+ Added snow to Excavation blocks
+ Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level.
+ Added extra settings to config.yml for "Call of the Wild" (Taming)
+ Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. Plus a config option to disable
+ Added new API methods to ExperienceAPI to get a players rank on the leaderboards
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
+ Added new McMMOPlayerLevelChangeEvent, fired when a players level changes
+ Added new McMMOPlayerLevelDownEvent, fired when a player loses levels
+ Added ability to give custom names to items in treasures.yml - use the key "Custom_Name" to set, expects a string.
+ Added ability to give lore to items in treasures.yml - use the key "Lore" to set, expects a list of strings.
+ Added Quartz and Name Tags to the default Excavation treasures
+ Added a warning message if the server is running NoCheatPlus without CompatNoCheatPlus
+ Added cooldown to commands with heavy database access to prevent denial of service
+ Added /mcscoreboard keep, to keep the scoreboard up forever
+ Added Rainbow Mode to scoreboards
+ Added new /mccooldowns command to show all ability cooldowns
+ Commands may now both print text and display a scoreboard
+ Killing a custom entity will automatically add it to the custom entity config file with default values.
= Fixed bug which allowed players to bypass fishing's exploit prevention
= Fixed bug where FakeEntityDamageByEntityEvent wasn't being fired
= Fixed bug with "Skull Splitter" not finding the locale string
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
= Fixed a bug with "Beast Lore" when the entity had no owner but was tamed.
= Fixed a bug where AbilityDeactivateEvent would throw an error if the player logged out before his ability ran out.
= Fixed a bug where LevelUpEvent would be called for an offline player.
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
= Fixed a bug where squid were not awarding XP.
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed default XP multiplier for repairing shears
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
! Changed fishing exploit prevention, by default it will no longer send global sounds, effects and messages.
! Changed Hardcore modes, they will also subtract experience
! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
! Hardcore modes can now be toggled for each skill individually
! Vampirism can now be enabled without having Skill Death Penalty enabled
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Improved "Tree Feller" algorithm (Thanks Riking!)
! Improved AFK Acrobatics prevention mechanism
! Improved profile saving
! Improved partial name matcher
! Improved update checker
! Updated localization files
! Party item share category states are now saved when the server shuts down.
! When using "Super Breaker" or "Giga Driller" abilities extra tool durability is used (again)
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
! Massively improved scoreboard handling
! Reworked scoreboard configuration (config.yml) - **you will need to update**
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
- Removed SpoutPlugin support
Version 1.4.06
+ Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop)
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
+ Added tab-complete support for all commands
+ Added ability to configure drops from Shake in treasures.yml
+ Added "Master Angler" ability to Fishing.
+ Added health display for mobs during combat.
+ Added new API method to McMMOPlayerLevelUpEvent to set levels gained
+ Added new permission node for /ptp; mcmmo.commands.ptp.send (enabled by default)
+ Added configurable cooldown and warmup times when using /ptp
+ Added a new Party item share category "Misc" which contains a list of configurable items. (By default all tools and armor)
+ Added fishing exploit prevention
+ Added permission node to bypass the fishing exploit prevention
+ Added boosts to Fishing chance depending on conditions
+ Added McMMOAbilityActivateEvent and McMMOAbilityDeactivateEvent
+ Added config option to toggle the size of fireworks
+ Added config option to multiply xp gains from mob spawner mobs
+ Added multiplier to Archery XP based on bow force
+ Added information about /party itemshare and /party expshare to the party help page
+ Added option to use scoreboards for power level display instead of Spout.
+ Added permission node to prevent inspecting hidden players
+ Added SQL to Flatfile database conversion
+ Added ability to use custom database managers and convert to/from them
= Fixed bug which could cause the server to hang for a minute when checking for updates. (Thanks to Riking)
= Fixed bug where spawned arrows could throw ArrayIndexOutOfBoundsException
= Fixed bug where custom Spout titles were overwritten by mcMMO.
= Fixed bug where Nether Quartz wasn't included in Smelting or item sharing
= Fixed bug where players were able to join the same party multiple times
= Fixed displaying partial names when trying to use /ptp
= Fixed wolves from Call of the Wild only having 8 health
= Fixed bug where /party chat was not working
= Fixed bug where experience commands were adding levels to all skills when they shouldn't
= Fixed mcmmo.commands.ptp.send not being set by default
= Fixed NPE when trying to tab-complete /mctop
= Fixed Fishing treasures always having the same enchants
= Fixed Smelting returning ink sacs instead of Lapis when double-dropping
= Fixed bug where players could remain in party chat after leaving or being kicked from a party.
= Fixed bug where non-player arrows couldn't be deflected.
= Fixed experience being applied even when the permission for a skill was denied
= Fixed possible item duplication bug with infinity bows
= Fixed bug with removing players from mySQL database
= Fixed bug with empty metadata lists and Smelting
= Fixed bug where Blast Mining would drop wrong items
= Fixed bug with Blast Mining where the Ability refreshed message was being send too early
= Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed
= Fixed bug where lucky perks where not working
= Fixed bug with Ice Fishing on a single block of ice
= Fixed bug with Ice Fishing which allowed players to break ice in protected areas
= Fixed a small bug with mob healthbars and bosses, such as EnderDragons and Withers
! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
! Changed Berserk to add items to inventory rather than denying pickup
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)
! Changed Chimaera Wing's recipe result to use the ingredient Material
! Changed Repair to ask a confirmation of the player when he tries to repair an enchanted item
! Players will no longer pickup items to their hotbar while using Unarmed
! ExperienceAPI methods will now throw InvalidSkillException if the skill name passed in is invalid.
! Changed default value for recently-hurt cooldown between teleports, this is also fully configurable now
! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
! Items dropped by players are now being tracked and are not being shared with party members
! Optimized tracking of tool & ability cooldowns.
! Updated the localization files
Version 1.4.05
+ Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
+ Added fireworks effects when a player levels-up, for every 100 levels (configurable)
= Fixed bug where /addxp was setting instead of adding experience
= Fixed bug where /addxp was not processessing level-ups for online players
= Fixed bug which allowed players to share experience with nearby dead players
= Fixed bug with ChimaeraWings not taking Wings from a players inventory properly
= Fixed bug which caused a NPE when trying to use /mctop smelting
= Fixed Berserk misbehaving when /reload was used
= Fixed parties misbehaving when /reload was used
= Fixed Berserk getting "stuck" when /mcrefresh was used
= Fixed ClassCastException with Taming
= Fixed huge mushroom blocks not being properly tracked
= Fixed potion buff option not using the appropriate # of ticks
= Fixed Chimera Wing spamming console if Metrics was disabled
= Fixed Chimera Wing displaying warmup message if warmup was set to 0
= Fixed party & admin chat errors when not aysnc
! Updated localization files
Version 1.4.04
+ Added functions to ExperienceAPI for use with offline players
+ Added Nether Quartz Ore to Mining
+ Added Dropper, Hopper, and Trapped Chest to blocks that shouldn't activate abilities
+ Added partial name matching
= Fixed bug where trying to activate a Chimaera Wing would require one item too much
= Fixed bug where Treefeller would try to cut too many leaves and reach the threshold when it shouldn't
= Fixed bug where Mining wasn't awarding double drops
= Fixed bug where Shake wouldn't damage mobs whose max health was less than 4
= Fixed bug where the API would fail if the name of a player's current party is requested when the player isn't in one (Thanks @dualspiral!)
= Fixed bug with retrieving a player's party members
= Fixed bug which caused a NPE when trying to join the party of a non-existing player or when ptp to a non-existing player
= Fixed bug which causes a NPE when trying to use /mcrefresh from the console
= Fixed bug where Carrots and Potatoes weren't awarding Herbalism XP.
= Fixed bug where some herbalism drops weren't properly shared within parties.
= Fixed bug where players wouldn't be able to pick up items if they logged our while Berserk was still active.
! Changed config node name for the skill experience modifiers from "Experience.Formula.Multiplier.[Skill]" to "Experience.Formula.Modifier.[Skill]"
! Updated localization files
! mcMMO abilities can no longer be activated while in Creative mode
! Expanded ChatAPI to allow toggling of chat states for users
! Updated to EMetrics 0.0.4-SNAPSHOT
- Removed deprecated functions from API classes.
- Removed functions for getting the PlayerProfile - using API classes is preferred, but if not the McMMOPlayer should be used instead
- Removed Ender Dragon, Wither, and Witch from granting combat experience and related configuration options
Version 1.4.03
Version 1.4.03-dev
+ Added option to advanced.yml to determine the # of enchant levels used when buffing Super Breaker & Giga Drill Breaker
+ Improved stats display for child skills
+ Added cooldown between using Chimaera Wings
= Fixed bug with '/party chat (on|off)' and '/partychat (on|off)' not working
= Fixed bug with Repair not decreasing enchanting levels properly
= Fixed bug with Smelting not properly tracking furnaces
= Fixed bug with Blast Mining not dropping blocks correctly
@@ -675,10 +28,9 @@ Version 1.4.03
= Fixed bug where the 'mcmmo.commands.ptp.world.all' was registered twice
= Fixed bug where Beast Lore wouldn't work on friendly pets
= Fixed bug where Deflect was calculated based on the attacker, not the defender. (We really did this time!)
= Fixed bug where Treefeller would not deal durability damage when the axe "splinters into dozens of pieces"
! Moved the Salvage unlock level from config.yml to advanced.yml
! Changed how Chimaera Wings are acquired, you need to craft them now. (By default, use 5 feathers in a shapeless recipe)
! Changed how Chimaera Wings teleport players to the spawnpoint, will now check if the location is safe
! Queue mctop and mcrank commands when using mySQL
- Removed option to disable Salvage via the config file. This should be handled via permissions instead.
- Removed the option to use Woodcutting without an axe from the config file.
@@ -794,7 +146,7 @@ Version 1.4.00
! Changed Excavation to have individual XP values for each block type, rather than a base XP value.
! Changed the way party teleportation works. When using /ptp, the target player needs to confirm the teleport before it takes place. (Configurable)
! Changed BeastLore: Now also displays offline player names
! Changed net.shatteredlands.shatt.backup task to include ALL config files
! Changed backup task to include ALL config files
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff.
! Changed locales to fall back on English when translated strings cannot be found.
@@ -1017,7 +369,7 @@ Version 1.3.07
+ Added permission nodes for Treasure & Magic Hunter for Fishing
+ Added a permission node for Farmer's Diet
+ Added config options for enabling/disabling specific double drops
+ Added automatic zip net.shatteredlands.shatt.backup of flatfile database & config files
+ Added automatic zip backup of flatfile database & config files
+ Added config options to enable/disable specific skills for PVP & PVE
= Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down.
= Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick
@@ -1603,7 +955,7 @@ Fixed bug with randomly receiving Taming XP
mcmmo.users file moved into /plugins/mcMMO/FlatFileStuff/
Leaderboard files now moved into /plugins/mcMMO/FlatFileStuff/Leaderboards
Locale files now have the prefix locale_ instead of messages_
Locale files are now located inside com/com.gmail/com.gmail.nossr50/locale/ instead of com/com.gmail/com.gmail.nossr50/
Locale files are now located inside com/gmail/nossr50/locale/ instead of com/gmail/nossr50/
Updated the code that handles permissions (this may mean 3.1.6 will finally play well!)
Some more source code organization
Fixed warnings for compiler

View File

@@ -1,234 +0,0 @@
# **Version 2.1.0+**
### Please use Spigot or Paper!
* **mcMMO is now built against Spigot-API instead of Bukkit**
### New Level Scaling
* mcMMO now features an optional 1-100 scaling mode!
* This is on by default for new installs, if you are upgrading mcMMO you will be put into Retro Mode instead (1-1000) scaling.
* The two scaling modes are the same, the changes are completely cosmetic!
* Skill Requirements in the config file will be multiplied by 10 if you are using Retro mode unless the setting has Retro in its name, keep this in mind if you need to edit anything!
### WorldGuard Support
* Added support for WorldGuard regions!
* `mcmmo` region flag turns on or off a players ability to use anything related to mcMMO other than commands
* `mcmmo-xp` region flag turns on or off a player's ability to gain XP
* These flags default to on unless you specify otherwise
### World Blacklist
* You can now disable mcMMO completely for specific worlds via `world_blacklist.txt` in /plugins/mcMMO/
* This file appears once mcMMO has been run at least once
* Every line of this file should be the name of a world where you don't want mcMMO to be enabled!
### Rank System
* Skills that are not yet unlocked will show up as `???` until learned
* Many skills now make use of a rank system!
* Rank level requirements are modified in `skillranks.yml`
* Woodcutting's Double Drop subskill is now named Harvest Lumber
* Archery's Skill Shot now uses a rank system
* Swords' Bleed now uses a rank system
* Swords' Counter Attack now uses a rank system
* Axe's Axe Mastery now uses a rank system
* Axe's Impact now uses a rank system
* Herbalism's Farmer's Diet now uses a rank system
* Herbalism's Green Thumb now uses a rank system
* Shake now uses a rank system
* Flux Mining now uses a rank system
* Removed traps from fishing
* Dodge now uses a rank system
* Arrow Retrieval now uses a rank system
* Axes' Critical Strikes now uses a rank system
* Axes' Greater Impact now uses a rank system
* Taming's Beast Lore now uses a rank system
* Taming's Gore now uses a rank system
* Taming's Call of the Wild now uses a rank system
* Taming's Pummel now uses a rank system
* Green Thumb now uses a rank system
* Farmer's Diet & Fisherman's Diet now use a rank system
### mcMMO Chat Alerts
* mcMMO no longer spams your chat!
* Most messages are sent to your action bar instead!
* Completely configurable! You can have mcMMO spam your chat again if you want!
* You can configure it so that messages will be sent to your action bar AND your chat system!
* Improved some of the messages sent to the player regarding the Chimaera Wing
### Localization File
* The descriptions of a few skills have changed
* Locale files now support & codes for colors and formatting!
* Added locale strings for new Woodcutting abilities
* Added locale strings for mcchatspy command
* Added locale strings for JSON integration
* Added locale strings for Taming's Pummel SubSkill
* Added locale strings for Unarmed's Block Cracker SubSkill
* Removed localizations with the following codes for being almost empty: `id`, `HR_hr`, `et_EE`, `lv`, `lt`, `no`, `pl_PL`, `pt_PT`, `tr_TR`
* Removed redundant information from some skill names and descriptions `en_US` (other locales will need to be updated)
* SubSkill locale keys are now located at `{ParentSkill}.SubSkill.SubSkillName`
* Super Abilities no longer have `(ABILITY)` in their `Skill.Effect` strings
### UI
* Certain elements of mcMMO's UI have been restyled
* Skills can now be clicked on and hovered over for more information!
* Added links to mcMMO related websites to various commands
* Customizeable and optional XP Bars
* Added the tagline "Overhaul Era" to various locations until 3.0.0 comes out
* Added option to disable the new URL links to `config.yml`
### Sounds
* Volume and Pitch of sounds can now be configured in the new `sounds.yml` file
### Super Ability Changes
* Skill Super Abilities now use a rank system, the default rank to unlock is level 5
* Activating Super abilities plays a sound (other plays can hear this)
* Ability Lengths now have a default skill cap at which they stop increasing in length
* Setting the cap to 0 removes it!
* Configurable in `advanced.yml` (endurance perks extend this limit)
### Skills
* mcMMO now notifies you when you progress in a skill!
* Excavation Treasure Hunter is renamed to Archaeology
* Readying a tool for a super ability now plays a sound
* Skill Unlock Notifications have sounds
* Stripping wood and right clicking on stripped wood will no longer ready your Axe
* Added new skill 'Understanding The Art' which adds nothing new but tracks previously hidden benefits of raising a skill
* Tool alerts now are sent to the Action Bar
* Super Ability activation alerts are now sent to the Action Bar
* Almost all Skill-related messages are now sent to the Action Bar
* Added some missing information to skill stats
* Swords no longer require blocking with a shield to trigger counter attacks
* Sword's Bleed has been renamed to Rupture
* Sword's Rupture no longer has an internal hard coded limit
* Sword's Serrated Strikes now uses your Rupture rank to determine the damage/ticks for its bleed effect.
* Sword's Rupture now ticks four times as fast
* Sword's Rupture now refreshes bleed duration instead of adding duration when applying bleed to the same target
* Sword's Rupture will now deal lethal damage
* Sword's Rupture now reaches its max proc chance at level 20 (200 in Retro)
* Sword's Rupture now has a max chance to proc of 33% instead of 70%
* Sword's Rupture now deals 50% more damage at above Rank 3 and can last much longer!
* The base damage for Bleed has been increased as well (update your `advanced.yml` admins)
* Sword's Rupture no longer triggers invincibility frames when damaging your opponent
* Sword's Rupture now plays a sound
* Taming's Gore now uses Rupture Rank 1 for its DoT calculations
* Furnaces now give XP to the last person to modify their inventory instead of the first person to open them
* Rolling now plays a sound (Graceful Roll has a different sound :) )
* Acrobatics' Roll exploit detection was tweaked to still allow for Roll to trigger even if it rewards no XP
* Acrobatics' Roll & Gracefull Roll are now considered the same skill (both mechanics are still there)
* Some skill level rank requirements have changed
### Experience
* Skills now start at level 1 (configurable in advanced.yml)
* Starting an XP event will now use the title API (toggle this in `advanced.yml`)
* The XP values of fish are now based on their rarity and have been drastically changed
* Coral (blocks) now give Mining XP
* Coral (plants) now give Herbalism XP
* Blue Ice now gives Mining XP
* Dolphins now give combat XP
* Drowned mobs now count towards combat XP
* Added missing mushroom blocks for XP
* You can now set guaranteed minimum values for XP gained if diminishing returns are enabled, this value defaults to 5% (`experience.yml`)
### Bug Fixes
* Fixed the bug where mob names would be replaced by hearts
* Fixed a bug where Rupture would apply an incorrect amount of bleed ticks
* Fixed bug where XP rate could be a negative number
* Fixed a bug where you could set a players levels into the negative and bad things would happen
* Fixed an edge case bug where Blast Mining wouldn't inform the player that it was on cooldown
### Plugin Compatibility
* mcMMO now fires new custom events relating to changes it makes to player scoreboards, plugin authors can listen to these events to improve compatibility
### Exploit Fixes
* Prevented exploits involving blocks made from entities (snowmen, etc..)
* Chimaera Wing now tracks cooldowns between sessions for players (no more disconnect abuse)
* Tridents will no longer be considered unarmed
* Prevented exploits involving 2 high herbs and chorus flowers
* Vastly Improved the Acrobatics exploit detection checks
### Parties
* Parties can now have size limits (configurable in `config.yml`), party size is unlimited by default
* You can now turn on Friendly Fire for parties in `config.yml`
* Party member list will only include members of the party that you can see (aren't vanished)
### Scoreboards
* Scoreboards are now disabled by default since most of their functionality is handled better by XP bars.
* Added toggle to disable all scoreboards (previously you had to disable them one by one)
* You can turn them back on in `config.yml`
* You can have XP bars and scoreboards on at the same time
### MySQL
* Added support for SSL for MySQL/MariaDB in config.yml (On by default)
* mcMMO no longer spams your console if you are not using SSL for your MySQL server
* You can now inspect offline players
* When converting from MySQL to flatfile mcMMO will now properly include all users in the conversion process
### Admins
* Added ability for admins to spy on party chat (off unless toggled on) /mcchatspy
* The Debug stick can now tell you about properties of a block related to Excavation
### API
* Detailed guide to API changes is available at http://api.mcmmo.org
* Added many missing `SubSkills` to `SubSkillType` class
* Moved a lot of methods from `SkillCommand` to `SkillUtils`
* `SkillType` is now `PrimarySkillType`
* `SecondarySkill` is now `SubSkillType`
* `AbilityType` is now `SuperAbilityType`
* `SecondaryAbilityEvent` is now `SubSkillEvent`
* `SubSkillType` has had many helpful methods added to it
* `GREEN_THUMB_PLANT` & `GREEN_THUMB_BLOCK` are replaced by `GREEN_THUMB`
### Permissions
* Removed all mob health bar permissions, this is no longer a per-player setting.
* Added permission node `mcmmo.commands.mcchatspy` & `mcmmo.commands.mcchatspy.others`
* Added `mcmmo.commands.mmoinfo` for the new `mmoinfo`/`mcinfo` command
* Added permission nodes for Harvest Lumber, Splinter, Nature's Bounty, and Bark Surgeon
* Call of the wild now uses `mcmmo.ability.taming.callofthewild` instead of `mcmmo.ability.taming.callofthewild.all`
* Replaced the old Double Drop permission node for woodcutting with a new Harvest Lumber permission node
* Fast Food Service permission node renamed to `mcmmo.ability.taming.fastfoodservice`
* Counter Attack permission node renamed to `mcmmo.ability.swords.counterattack`
* Arrow Deflect permission node renamed to `mcmmo.ability.unarmed.arrowdeflect`
* Iron Arm Style permission node renamed to `mcmmo.ability.unarmed.ironarmstyle`
### Commands
* Added new info command `/mmoinfo` or `/mcinfo`
* Added toggle command `/mcchatspy`
* `/mcMMO help` no longer displays the other/special commands category to players lacking permissions
* Removed the `mobhealthbar` command, this is no longer a per-player setting.
### Misc Config Changes
* Removed `SkillShot`'s `IncreaseLevel` & `IncreasePercentage` (replaced by `RankDamageMultiplier`)
* Removed `AxeMastery`'s `MaxBonus` & `MaxBonusLevel` (replaced by `RankDamageMultiplier`)
* `Unarmed.IronArm` in `advanced.yml` is now `Unarmed.IronArmStyle`
* `Unarmed.Deflect` in `advanced.yml` is now `Unarmed.ArrowDeflect`
* `Swords.Counter` in `advanced.yml` is now `Swords.CounterAttack`
* `Archery.Retrieve` in `advanced.yml` is now `Archery.ArrowRetrieval`
* `Axes.CriticalHit` in `advanced.yml` is now `Axes.CriticalStrikes`
* Archery's Skill Shot now uses `RankDamageMultiplier` for its damage bonus calculations
* Axe's Axe mastery now uses `RankDamageMultiplier` for its damage bonus calculations
### Misc Changes
* Removed everything involving the kraken
* Code cleanup in a lot of places... unfortunately there is still much left to do!

View File

@@ -1,66 +1,47 @@
# mcMMO
## The RPG lovers mod
## Website
I'm working on a brand new website for mcMMO
You can check it out here http://www.mcmmo.org
I plan to post links to our new wiki (its still under development), downloads, and dev blogs there.
### Contributing
As the plugin is being developed for multiple Minecraft versions, and multiple Minecraft platforms (read: [sponge](https://spongepowered.org/), [spigot](https://spigotmc.org/), bukkit, and [paper](https://papermc.io)), the
overall build process is handled by [Gradle](https://gradle.org/) with [Kotlin-dsl](https://github.com/gradle/kotlin-dsl) based scripts.
As such, an IDE is strongly recommended when attempting to contribute features, additions, changes, bug fixes, etc. to mcMMO as the scripts handle a
majority of our dependencies and rebuilding a production worthy jar.
To get started, a few things need to be installed:
- JDK 8 (not 9, 10, 11, or 7)
- git
- Your favorite IDE (can be [Eclipse](https://eclipse.org/), [IntelliJ](https://jetbrains.org/)
- BuildTools.jar from [Spigot](https://www.spigotmc.org/wiki/buildtools/)
##### Using BuildTools
BuildTools is used to generate the craftbukkit/spigot dependencies used for varoius versions of Minecraft.
The key with this tool is that it can build and deploy multiple vesions of Minecraft based on "reviewions".
### Builds
Currently, you can obtain our builds via the Spigot resource page: https://spigot.mcmmo.org
### Dev builds
Our latest development builds are available [here](http://ci.mcmmo.info).
### Brief Description
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.
If you want an original RPG experience like no other mod out there, mcMMO is for you.
## About the Team
mcMMO is currently developed by a team of individuals from all over the world.
### Project Lead & Founder
[![com.gmail.nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/com.gmail.nossr50)
### Former Lead
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin)
### Glorious Leader
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)]
(https://github.com/gmcferrin)
### Developers
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)](https://github.com/bm01)
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)](https://github.com/Glitchfinder)
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)](https://github.com/NuclearW)
[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)](https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)](https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)](https://github.com/riking)
### Special thanks
[![EasyMFnE](https://www.gravatar.com/avatar/99c9a1fa3bbf957791ceac7b45daadb0.png)](https://github.com/EasyMFnE)
Added the Alchemy skill
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)]
(https://github.com/bm01)
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)]
(https://github.com/Glitchfinder)
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)]
(https://github.com/nossr50)
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)]
(https://github.com/NuclearW)
[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)]
(https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)]
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/??.png)]
(https://github.com/t00thpick1)
## Compiling
mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
mcMMO uses Maven 3 to manage dependancies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
The typical command used to build mcMMO is: `mvn clean package install`
The typical command used to build mcMMO is: mvn clean package install
Required Libraries:
* Bukkit
* Spout API
* JUnit
* Metrics
* Bukkit
https://spigot.mcmmo.org for more up to date information.
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.

View File

@@ -1,139 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
/*
* Declares the version of the Gradle wrapper. We need 4.9 for now because
* ForgeGradle 3+ is a hard dependency for Gradle 4.9, 4.10 is not compatible
*/
val wrapper by tasks.getting(Wrapper::class) {
gradleVersion = "4.9"
}
/*
* Sets up project references to be used in child scripts, like
* ":bukkit", ":core", ":sponge" where these projects need to be
* referred to for dependencies, paths, outputs etc.
* Projects is specifically an object stored in <root>/buildSrc/src/main/java/Config.kt
* It's a nullable variable, but we just store it here and use it elsewhere.
*/
Projects.core = project("core")
Projects.bukkit = project("bukkit")
Projects.sponge = project("sponge")
/*
Declares the various other projects and stores them to Gradle's `extra` properties.
These are potentially usable for other purposes, but for now, they're here only to
declare the values for this root project's dependency (for shadowjar)
*/
var core: Project by extra { project("core") }
val bukkit by extra { project("bukkit") }
val bukkit_18 by extra { bukkit.project("1_8_8") }
val bukkit_112 by extra { bukkit.project("1_12") }
val bukkit_113 by extra { bukkit.project("1_13") }
val sponge by extra { project("sponge") }
val sponge_7 by extra { sponge.project("api7") }
group = properties["pluginGroup"]!!
version = properties["pluginVersion"]!!
/*
Even though all projects declares some of these plugins, we want to declare them the traditional
way so that we can have IDE utiliziation and processing, it helps with writing these scripts.
*/
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version "4.0.4"
}
/*
Default management for ALL projects, not just root, or ":bukkit", but all projects and
their children projects.
*/
allprojects {
/*
We need the java library processing, and shadow allows us to run
shadowJar to relocate dependencies and bundle dependencies into a fat jar.
*/
apply(plugin="java-library")
apply(plugin="com.github.johnrengelman.shadow")
/*
Defines all the repositories for all project dependency resolutions. Some of these
repositories are meant for specific dependencies, so the content filters will
prevent attempts at resolving those dependencies being requested at those repositories.
Constants are defined in <root>/buildSrc/src/main/java/Config.kt
*/
repositories {
mavenCentral()
maven(Repos.sk89q) // WorldEdit/WorldGuard
maven(Repos.bstats) // bstats
maven(Repos.sponge) // Sponge, Configurate, and some other things
maven(Repos.spigot) // Spigot and Bukkit
maven(Repos.sonatype) // General Maven
mavenLocal() // For nms packages
}
// Sets all projects compatibility level to Java 8
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// Encoding for all packages is UTF-8
tasks.getting(JavaCompile::class) {
options.encoding = "UTF-8"
}
// Default shadow jar configuration. Sub projects will override and add on,
// but this sets up at the very least the jdbc connection dependencies to be relocated
val shadowJar by tasks.getting(ShadowJar::class) { // Configure basics of relocation
relocate(Shadow.Origin.juli, Shadow.Target.juli)
relocate(Shadow.Origin.tomcat, Shadow.Target.tomcat)
exclude(Shadow.Exclude.ForgeGradle.dummyThing)
exclude(Shadow.Exclude.ForgeGradle.template)
}
}
/*
All subprojects shadowjar tasks that will exclude various dependencies, while
the root project will include some of these dependencies (like jdbc, configurate)
so that the sub project jars are already somewhat minimized, in the event those
platform jars are to be deployed individually versus an overall "all platforms"
jar.
*/
subprojects {
val shadowJar by tasks.getting(ShadowJar::class) {
dependencies {
exclude(dependency("${Deps.Groups.sponge}:${Deps.Modules.configurate_yaml}"))
exclude(dependency(Shadow.Exclude.guava))
exclude(dependency(Shadow.Exclude.snakeyaml))
exclude(dependency(Shadow.Exclude.tomcat))
exclude(dependency(Shadow.Exclude.juli))
}
}
}
// Sets up this root project to depend on all the implementations supported.
// By default, they all already should have shadow relocations and packaging,
// and their dependencies should not be leaking into this project.
dependencies {
compile(bukkit)
compile(sponge)
compile(bukkit_18)
compile(bukkit_112)
compile(bukkit_113)
compile(sponge_7)
}
// Configure shadow for the root project, we want to relocate bstats-bukkit
// and whatever else is configured in the allProjects configuration
val shadowJar by tasks.getting(ShadowJar::class) { // Root shadow relocation
relocate(Shadow.Origin.bstatsBukkit, Shadow.Target.bstatsBukkit)
baseName = "mcMMO"
classifier = "bundle"
}
// Tell the build task to depend on shadowjar.
val build by tasks
build.dependsOn(shadowJar)

View File

@@ -1,8 +0,0 @@
plugins {
`kotlin-dsl`
}
repositories {
jcenter()
}

View File

@@ -1,191 +0,0 @@
@file:Suppress("MayBeConstant", "unused")
import org.gradle.api.Project
object Plugins {
const val spongeGradleId = "${Deps.Groups.sponge}.plugin"
object FG2_3 {
const val classpath = "net.minecraftforge.gradle:ForgeGradle:${Versions.fg23}"
const val extensionName = "minecraft"
const val id = "net.minecraftforge.gradle.forge"
}
}
object Repos {
const val sk89q = "https://maven.sk89q.com/repo"
// bStats
const val bstats = "https://repo.codemc.org/repository/maven-public"
// configurate
const val sponge = "https://repo.spongepowered.org/maven/"
const val spigot = "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
const val sonatype = "https://oss.sonatype.org/content/repositories/snapshots"
const val forge = "https://files.minecraftforge.net/maven/"
}
object Config {
object Libs {
const val configurate = "${Deps.Groups.sponge}:${Deps.Modules.configurate_yaml}:${Versions.configurate}"
const val jdbc = "${Deps.Groups.tomcat}:${Deps.Modules.jdbc}:${Versions.jdbc}"
const val juli = "${Deps.Groups.tomcat}:${Deps.Modules.juli}:${Versions.jdbc}"
const val junitDep = "${Deps.Groups.junit}:${Deps.Modules.junit}:${Versions.junit}"
const val flowmath = "${Deps.Groups.flowpowered}:${Deps.Modules.flowmath}:${Versions.flowmath}"
object Bukkit {
object `1_8` {
const val api = "$bukkit:${Versions.bukkit18}"
const val spigotApi = "${Bukkit.spigotApi}:${Versions.bukkit18}"
const val spigot = "$${Bukkit.spigot}:${Versions.bukkit18}"
const val nms = "$craftbukkit:${Versions.bukkit18}"
// only legacy existed at this point, no core.
const val wgLegacy = "${Bukkit.wgLegacy}:${Versions.wg18}"
}
object `1_12` {
const val api = "$bukkit:${Versions.bukkit112}"
const val spigotApi = "${Bukkit.spigotApi}:${Versions.bukkit112}"
const val spigot = "$${Bukkit.spigot}:${Versions.bukkit112}"
const val nms = "$craftbukkit:${Versions.bukkit112}"
// only legacy existed at this point, no core.
const val wgLegacy = "${Bukkit.wgLegacy}:${Versions.wg112}"
}
object `1_13` {
const val api = "$bukkit:${Versions.bukkit113}"
const val spigotApi = "${Bukkit.spigotApi}:${Versions.bukkit113}"
const val spigot = "$${Bukkit.spigot}:${Versions.bukkit113}"
const val nms = "$craftbukkit:${Versions.bukkit113}"
const val wgCore = "${Bukkit.wgCore}:${Versions.wg113}"
const val wgLegacy = "${Bukkit.wgLegacy}:${Versions.wg113}"
}
const val bukkit = "${Deps.Groups.bukkit}:${Deps.Modules.bukkit}"
const val craftbukkit = "${Deps.Groups.bukkit}:${Deps.Modules.craftbukkit}"
const val wgCore = "${Deps.Groups.worldguard}:${Deps.Modules.wgCore}"
const val wgLegacy = "${Deps.Groups.worldguard}:${Deps.Modules.wgLegacy}"
const val spigotApi = "${Deps.Groups.spigot}:${Deps.Modules.spigotApi}"
const val spigot = "${Deps.Groups.spigot}:${Deps.Modules.spigot}"
const val bstats = "${Deps.Groups.bstats}:${Deps.Modules.bstatsBukit}:${Versions.bstats}"
}
object Sponge {
object API7 { // All of these are specific to the API7 module, API8 will change
const val forgeGradleId = "net.minecraftforge.gradle.forge"
const val spongeGradleId = "${Deps.Groups.sponge}.plugin"
const val spongeGradleVersion = "0.9.0"
const val api = "${Sponge.api}:${Versions.sapi7}"
const val common = "${Sponge.common}:${Versions.spongeImpl7}"
const val forge_version = "14.23.5.2768"
const val minecraftVersion = "1.12.2-$forge_version"
const val mappings = "snapshot_20180808"
}
object Exclude {
const val group = Deps.Groups.sponge
const val module = Deps.Modules.spongeAPI
}
const val api = "${Deps.Groups.sponge}:${Deps.Modules.spongeAPI}"
const val common = "${Deps.Groups.sponge}:${Deps.Modules.spongecommon}"
const val bstats = "${Deps.Groups.bstats}:${Deps.Modules.bstatsSponge}:${Versions.bstats}"
}
}
}
object Deps {
object Groups {
const val nossr = "com.gmail.nossr50"
const val google = "com.google"
const val guava = "com.google.guava"
const val gson = "com.google.code.gson"
const val yaml = "org.yaml"
const val sk89q = "com.sk89q"
const val apache = "org.apache"
const val worldguard = "$sk89q.worldguard"
const val worldedit = "$sk89q.worldedit"
const val sponge = "org.spongepowered"
const val spigot = "org.spigotmc"
const val md5 = "net.md_5"
const val bukkit = "org.bukkit"
const val bstats = "org.bstats"
const val tomcat = "org.apache.tomcat"
const val junit = "junit"
const val checker = "org.checkerframework"
const val flowpowered = "com.flowpowered"
}
object Modules {
const val guava = "guava"
const val gson = "gson"
const val snakeyaml = "snakeyaml"
const val wgCore = "worldguard-core"
const val wgLegacy = "worldguard-legacy"
const val bungeecordChat = "bungeecord-chat"
const val spongeAPI = "spongeapi"
const val spongecommon = "spongecommon"
const val spongeforge = "spongeforge"
const val spongevanilla = "spongevanilla"
const val bukkit = "bukkit"
const val craftbukkit = "craftbukkit"
const val bstatsBukit = "bstats-bukkit"
const val bstatsSponge = "bstats-sponge"
const val spigotApi = "spigot-api"
const val spigot = "spigot"
const val configurate = "configurate"
const val configurate_core = "${configurate}-core"
const val configurate_yaml = "${configurate}-yaml"
const val jdbc = "tomcat-jdbc"
const val juli = "tomcat-juli"
const val junit = "junit"
const val checker = "checker-qual"
const val flowmath = "flow-math"
}
}
object Projects {
var core: Project? = null
var bukkit: Project? = null
var sponge: Project? = null
}
object Shadow {
object Origin {
const val juli = "${Deps.Groups.apache}.juli"
const val tomcat = "${Deps.Groups.apache}.tomcat"
const val apache = "${Deps.Groups.apache}.commons.logging"
const val bstatsBukkit = "${Deps.Groups.bstats}.bukkit"
const val configurate = "ninja.leaping.configurate"
const val checker = "org.checkerframework"
}
object Target {
const val juli = "${Deps.Groups.nossr}.database.tomcat.juli"
const val tomcat = "${Deps.Groups.nossr}.database.tomcat"
const val apache = "${Deps.Groups.nossr}.commons.logging"
const val bstatsBukkit = "${Deps.Groups.nossr}.metrics.bstat"
const val configurate = "${Deps.Groups.nossr}.${Deps.Modules.configurate}"
const val checker = "${Deps.Groups.nossr}.${Deps.Modules.configurate}.checkerframework"
}
object Exclude {
const val tomcat = "${Deps.Groups.tomcat}:${Deps.Modules.jdbc}"
const val juli = "${Deps.Groups.apache}:${Deps.Modules.juli}"
const val guava = "${Deps.Groups.guava}:${Deps.Modules.guava}"
const val snakeyaml = "${Deps.Groups.yaml}:${Deps.Modules.snakeyaml}"
const val bukkit = Deps.Groups.bukkit
const val spigot = Deps.Groups.spigot
const val sk89q = "com.sk89q"
const val wg = "$sk89q.worldguard"
const val intake = "$sk89q.intake"
const val flyway = "com.flywaydb"
const val khelekore = "org.khelekore"
const val findbugs = "com.google.code.findbugs"
const val bstats = "${Deps.Groups.bstats}"
object ForgeGradle {
const val dummyThing = "dummyThing"
const val template = "Version.java.template"
}
}
}

View File

@@ -1,16 +0,0 @@
object Versions {
const val configurate = "3.6" // Latest configurate
const val flowmath = "1.0.4-SNAPSHOT"
const val bukkit18 = "1.8.8-R0.1-SNAPSHOT" // Last bukkit 1.8.8
const val bukkit112 = "1.12.2-R0.1-SNAPSHOT" // Last bukkit 1.12.2
const val bukkit113 = "1.13.2-R0.1-SNAPSHOT" // Latest bukkit
const val sapi7 = "7.1.0" // Latest SpongeAPI stable
const val spongeImpl7 = "7.1.5" // Latest SpongeCommon stable
const val jdbc = "7.0.52"
const val junit = "4.12"
const val fg23 = "2.3-SNAPSHOT" // ForgeGradle to support MC 1.12.2
const val wg18 = "6.1.2" // Bukkit/CraftBukkit/Spigot 1.8.8 supported build, works on newer, but last one to support 1.8.8
const val wg112 = "6.2" // Last WorldGuard to support 1.12
const val wg113 = "7.0.0-SNAPSHOT" // Latest WorldGuard to support 1.13.2
const val bstats = "1.4" // Supports all backwards compatible. Always relocated
}

View File

@@ -1,27 +0,0 @@
import Config.Libs.Bukkit.`1_12` as Bukkit
// Config is located in <root>/buildSrc/src/main/java/Config.kt
// It provides a bunch of constant values we use as dependency
// strings, so we don't have to duplicate a bunch of them in
// various scripts.
plugins {
java // This is already provided, but for static compilation,
// we declare it here so we can use the IDE static type references
}
/*
Dependency inheritance is as follows
- ":core", which provides
configurate, tomcat jdbc/juli, and flowmath. It excludes sub
dependencies like guava and apache commons lang.
- ":bukkit", which provides nothing on it's own, except the
core bukkit classes that can be built on 1.13.2 API (which may change).
It also defines all subprojects to depend on ":core", and ":bukkit",
and bstats-bukkit.
*/
dependencies {
compileOnly(Bukkit.api) // Bukkit API for 1.12.2
compileOnly(Bukkit.nms) // CraftBukkit for 1.12.2
compileOnly(Bukkit.wgLegacy) // WorldGuard for 1.12.2 bukkit
}

View File

@@ -1,106 +0,0 @@
package com.gmail.nossr50.bukkit.v1_12;
import com.gmail.nossr50.VersionedHandler;
import com.gmail.nossr50.mcMMO;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import net.minecraft.server.v1_12_R1.Chunk;
import net.minecraft.server.v1_12_R1.EntityTypes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.IBlockState;
import net.minecraft.server.v1_12_R1.MinecraftKey;
import net.minecraft.server.v1_12_R1.RegistryBlocks;
import net.minecraft.server.v1_12_R1.RegistryMaterials;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.block.CraftBlockState;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class NmsHandler extends VersionedHandler {
/**
* Static reference to the block registry. Don't really care about the fact that
* it is being stored as a reference here, but for imports reasons, it's smaller
* line length makes it optimal to read for method usages.
*/
private static final RegistryBlocks<MinecraftKey, net.minecraft.server.v1_12_R1.Block> BLOCK_REGISTRY = net.minecraft.server.v1_12_R1.Block.REGISTRY;
/**
* We can keep track of block state id's by generating them on demand, i.e., when
* they're being requested from Blocks, or BlockDatas.
*/
private static final RegistryMaterials<MinecraftKey, IBlockData> BLOCK_STATE_REGISTRY = new RegistryMaterials<>();
NmsHandler(mcMMO plugin) {
super(plugin);
}
@Override
public String getIdFor(Block block) {
// We have to get the underlying nms block by the block, which might as well just be the type id.
final Chunk chunk = ((CraftChunk) block.getChunk()).getHandle();
// Get the block state from the underlying chunk (stored by reference in CraftBlock)
final IBlockData blockState = chunk.a(block.getX(), block.getY(), block.getZ());
// Sadly, Mojang doesn't store the string id onto blocks, states, or any of their types, they just call the registry.
final MinecraftKey key = BLOCK_REGISTRY.b(blockState.getBlock());
return key.toString();
}
@Override
public String getIdFor(Entity entity) {
// Every entity knows it's "type". Here, we just use the right method getter to get the EntityTypes instance for that entity
final net.minecraft.server.v1_12_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
// And then... well. we get the string id from the registry, based on the entity class to id mapping in EntityTypes.
final MinecraftKey key = EntityTypes.a(nmsEntity);
// If the key is null, well, we've got bigger problems...
return key == null ? "minecraft:slime" : key.toString();
}
@SuppressWarnings("Duplicates")
@Override
public String getIdFor(BlockState block) {
// Since we don't really want to trust what "BlockState" gives us, and the API doesn't give us anything but
// what the API wants to give us, we have to dig into internals to get the true BlockState representation
final CraftBlockState craftState = (CraftBlockState) block;
// Because CraftBlock also stores the chunk reference, we can short cut in to use the chunk, instead of pinging
// the chunk map on WorldServer
final CraftChunk craftChunk = (CraftChunk) craftState.getChunk();
// Then query for the block state from the chunk.
final IBlockData nmsState = craftChunk.getHandle().a(block.getX(), block.getY(), block.getZ());
// And then we're gucci
final net.minecraft.server.v1_12_R1.Block nmsBlock = nmsState.getBlock();
final MinecraftKey blockKey = BLOCK_REGISTRY.b(nmsBlock);
// Now we can check if our blockstate registry actually has the block state.
final MinecraftKey stateKey = BLOCK_STATE_REGISTRY.b(nmsState);
if (stateKey != null) { // If the state has been registered by the handler, then by all means.
return stateKey.toString();
}
// If not, well, it needs to have a key generated and registered.
final String nameSpace = blockKey.getKey();
StringBuilder builder = new StringBuilder();
builder.append(nameSpace); // We only want to get the block id, not the domain id, since that's going to be appended later
// Get the full Property -> Value mapping for the block state
final ImmutableMap<IBlockState<?>, Comparable<?>> properties = nmsState.t();
if (!properties.isEmpty()) {
builder.append('[');
Joiner joiner = Joiner.on(',');
List<String> propertyValues = new ArrayList<>();
// Yadadadada, go through all property entries and add each as a string for the "propertyName=value" (like "variant=oak")
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : properties.entrySet()) {
// a() gets the inputted "name" for the state, the value, well, that gets the value, which is always toStringable.
propertyValues.add(entry.getKey().a() + "=" + entry.getValue());
}
builder.append(joiner.join(propertyValues));
builder.append(']');
}
// Now we can make the MinecraftKey...
final MinecraftKey newKey = new MinecraftKey(builder.toString());
BLOCK_STATE_REGISTRY.a(newKey, nmsState);
return newKey.toString();
}
}

View File

@@ -1,27 +0,0 @@
import Config.Libs.Bukkit.`1_13` as Bukkit
// Config is located in <root>/buildSrc/src/main/java/Config.kt
// It provides a bunch of constant values we use as dependency
// strings, so we don't have to duplicate a bunch of them in
// various scripts. The import allows us to "import as" for shorthand
plugins {
`java-library` // This is already provided, but for static compilation,
// we declare it here so we can use the IDE static type references
}
/*
Dependency inheritance is as follows
- ":core", which provides
configurate, tomcat jdbc/juli, and flowmath. It excludes sub
dependencies like guava and apache commons lang.
- ":bukkit", which provides nothing on it's own, except the
core bukkit classes that can be built on 1.13.2 API (which may change).
It also defines all subprojects to depend on ":core", and ":bukkit",
and bstats-bukkit.
*/
dependencies {
compileOnly(Bukkit.api) // Bukkit API for 1.13.2 - Defined in <root>/buildSrc/src/main/java/Config.kt
compileOnly(Bukkit.nms) // CraftBukkit-1.13.2-R0.1-SNAPSHOT - Defined in <root>/buildSrc/src/main/java/Config.kt
compileOnly(Bukkit.wgCore) // WorldGuard-core - Defined in <root>/buildSrc/src/main/java/Config.kt
compileOnly(Bukkit.wgLegacy) // WorldGuard-legacy - Defined in <root>/buildSrc/src/main/java/Config.kt
}

View File

@@ -1,101 +0,0 @@
package com.gmail.nossr50.bukkit.v1_13;
import com.gmail.nossr50.VersionedHandler;
import com.gmail.nossr50.mcMMO;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import net.minecraft.server.v1_13_R2.EntityTypes;
import net.minecraft.server.v1_13_R2.IBlockData;
import net.minecraft.server.v1_13_R2.IBlockState;
import net.minecraft.server.v1_13_R2.IRegistry;
import net.minecraft.server.v1_13_R2.MinecraftKey;
import net.minecraft.server.v1_13_R2.RegistryMaterials;
import net.minecraft.server.v1_13_R2.WorldServer;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlockState;
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
import org.bukkit.entity.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class NmsHandler extends VersionedHandler {
private static final IRegistry<net.minecraft.server.v1_13_R2.Block> BLOCK_REGISTRY = IRegistry.BLOCK;
private static final IRegistry<EntityTypes<?>> ENTITY_REGISTRY = IRegistry.ENTITY_TYPE;
/**
* We use {@link RegistryMaterials} because we don't want to default to another block state,
* if a {@link IBlockData} is not registered, we need to generate an ID and register that key to
* that {@link IBlockData}. By default, this should be populated during plugin startup by
* calling some init method, but that will be determined later.
*/
private static final IRegistry<IBlockData> BLOCK_STATE_REGISTRY = new RegistryMaterials<>();
NmsHandler(mcMMO plugin) {
super(plugin);
}
@Override
public String getIdFor(Block block) {
// We have to get the underlying nms block by the block, which might as well just be the type id.
final WorldServer world = ((CraftBlock) block).getCraftWorld().getHandle();
// The registry.c(T) will return MinecraftKey, and the toString() returns the "$mod:$name", so "minecraft:stone"
final IBlockData blockState = world.getType(((CraftBlock) block).getPosition());
// Sadly, Mojang doesn't store the string id onto blocks, states, or any of their types, they just call the registry.
final MinecraftKey key = BLOCK_REGISTRY.getKey(blockState.getBlock());
// Sometimes, there's a rare case with mods where the key is going to be null, but should never happen in bukkit/spigot.
return key == null ? "minecraft:air" : key.toString();
}
@Override
public String getIdFor(Entity entity) {
// Every entity knows it's "type". Here, we just use the right method getter to get the EntityTypes instance for that entity
final EntityTypes<?> entityType = ((CraftEntity) entity).getHandle().P();
// And then... well. we get the string id from the registry!
final MinecraftKey key = ENTITY_REGISTRY.getKey(entityType);
// If the key is null, well, we've got bigger problems...
return key == null ? "minecraft:slime" : key.toString();
}
@SuppressWarnings("Duplicates")
@Override
public String getIdFor(BlockState block) {
// Much like #getIdFor(Block) except here we have the "state" by numerical id. So.. we have to grab it from
// the world.
final CraftBlockState craftState = (CraftBlockState) block;
final IBlockData nmsState = craftState.getHandle();
final net.minecraft.server.v1_13_R2.Block nmsBlock = nmsState.getBlock();
final MinecraftKey blockKey = BLOCK_REGISTRY.getKey(nmsBlock);
// Now we can check if our blockstate registry actually has the block state.
final MinecraftKey stateKey = BLOCK_STATE_REGISTRY.getKey(nmsState);
if (stateKey != null) { // If the state has been registered by the handler, then by all means.
return stateKey.toString();
}
// If not, well, it needs to have a key generated and registered.
final String nameSpace = blockKey.getKey();
StringBuilder builder = new StringBuilder();
builder.append(nameSpace); // We only want to get the block id, not the domain id, since that's going to be appended later
// Get the full Property -> Value mapping for the block state
final ImmutableMap<IBlockState<?>, Comparable<?>> properties = nmsState.getStateMap();
if (!properties.isEmpty()) {
builder.append('[');
Joiner joiner = Joiner.on(',');
List<String> propertyValues = new ArrayList<>();
// Yadadadada, go through all property entries and add each as a string for the "propertyName=value" (like "variant=oak")
for (Map.Entry<IBlockState<?>, Comparable<?>> entry : properties.entrySet()) {
// a() gets the inputted "name" for the state, the value, well, that gets the value, which is always toStringable.
propertyValues.add(entry.getKey().a() + "=" + entry.getValue());
}
builder.append(joiner.join(propertyValues));
builder.append(']');
}
// Now we can make the MinecraftKey...
final MinecraftKey newKey = new MinecraftKey(builder.toString());
BLOCK_STATE_REGISTRY.a(newKey, nmsState);
return newKey.toString();
}
}

View File

@@ -1,23 +0,0 @@
import Config.Libs.Bukkit.`1_8` as Bukkit
plugins {
java
}
/*
Dependency inheritance is as follows
- ":core", which provides
configurate, tomcat jdbc/juli, and flowmath. It excludes sub
dependencies like guava and apache commons lang.
- ":bukkit", which provides nothing on it's own, except the
core bukkit classes that can be built on 1.13.2 API (which may change).
It also defines all subprojects to depend on ":core", and ":bukkit",
and bstats-bukkit.
*/
dependencies {
compileOnly(Bukkit.api) // Bukkit API for 1.8.8 - Defined in <root>/buildSrc/src/main/java/Config.kt
compileOnly(Bukkit.nms) // CraftBukkit-1.8.8-R0.3-SNAPSHOT - Defined in <root>/buildSrc/src/main/java/Config.kt
compileOnly(Bukkit.wgLegacy) // Old worldguard - Defined in <root>/buildSrc/src/main/java/Config.kt
}

View File

@@ -1,93 +0,0 @@
package com.gmail.nossr50.bukkit.v1_8;
import com.gmail.nossr50.VersionedHandler;
import com.gmail.nossr50.mcMMO;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import net.minecraft.server.v1_8_R3.Blocks;
import net.minecraft.server.v1_8_R3.EntityTypes;
import net.minecraft.server.v1_8_R3.IBlockData;
import net.minecraft.server.v1_8_R3.IBlockState;
import net.minecraft.server.v1_8_R3.MinecraftKey;
import net.minecraft.server.v1_8_R3.RegistryBlocks;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Entity;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@SuppressWarnings({"unused", "Duplicates"}) // We use reflection to load this handler on 1.8 versions
public class NmsHandler extends VersionedHandler {
/**
* Static reference to the block registry. Don't really care about the fact that
* it is being stored as a reference here, but for imports reasons, it's smaller
* line length makes it optimal to read for method usages.
*/
private static final RegistryBlocks<MinecraftKey, net.minecraft.server.v1_8_R3.Block> BLOCK_REGISTRY = net.minecraft.server.v1_8_R3.Block.REGISTRY;
/**
* We can keep track of block state id's by generating them on demand, i.e., when
* they're being requested from Blocks, or BlockDatas.
*/
private static final RegistryBlocks<MinecraftKey, IBlockData> BLOCK_STATE_REGISTRY = new RegistryBlocks<>(BLOCK_REGISTRY.c(Blocks.AIR)); // Default to AIR
NmsHandler(mcMMO plugin) {
super(plugin);
}
@Override
public String getIdFor(Block block) {
// We have to get the underlying nms block by the block, which might as well just be the type id.
final net.minecraft.server.v1_8_R3.Block block1 = CraftMagicNumbers.getBlock(block);
// The registry.c(T) will return MinecraftKey, and the toString() returns the "$mod:$name", so "minecraft:stone"
final MinecraftKey key = BLOCK_REGISTRY.c(block1);
return key.toString();
}
@Override
public String getIdFor(Entity entity) {
// EntityTypes maintains the maps of Class<? extends nms.Entity> to String for id's and to numerical id numbers.
// We of course are using the method that gets us the String id of the entity, such as "minecraft:creeper"
return EntityTypes.b(((CraftEntity) entity).getHandle());
}
@Override
public String getIdFor(BlockState block) {
// Much like #getIdFor(Block) except here we have the "state" by numerical id. So.. we have to grab it from
// the world.
final net.minecraft.server.v1_8_R3.Block nmsBlock = net.minecraft.server.v1_8_R3.Block.REGISTRY.a(block.getTypeId());
final MinecraftKey blockKey = net.minecraft.server.v1_8_R3.Block.REGISTRY.c(nmsBlock);
final IBlockData blockState = nmsBlock.fromLegacyData(block.getRawData());
// Now we can check if our blockstate registry actually has the block state.
final MinecraftKey stateKey = BLOCK_STATE_REGISTRY.c(blockState);
if (stateKey != null) { // If the state has been registered by the handler, then by all means.
return stateKey.toString();
}
// If not, well, it needs to have a key generated and registered.
final String nameSpace = blockKey.a();
StringBuilder builder = new StringBuilder();
builder.append(blockKey.a()); // We only want to get the block id, not the domain id, since that's going to be appended later
// Get the full Property -> Value mapping for the block state
final ImmutableMap<IBlockState, Comparable> properties = blockState.b();
if (!properties.isEmpty()) {
builder.append('[');
Joiner joiner = Joiner.on(',');
List<String> propertyValues = new ArrayList<>();
for (Map.Entry<IBlockState, Comparable> entry : properties.entrySet()) {
// a() gets the inputted "name" for the state, the value, well, that gets the value, which is always toStringable.
propertyValues.add(entry.getKey().a() + "=" + entry.getValue());
}
builder.append(joiner.join(propertyValues));
builder.append(']');
}
// Now we can make the MinecraftKey...
final MinecraftKey newKey = new MinecraftKey(builder.toString());
BLOCK_STATE_REGISTRY.a(newKey, blockState);
return newKey.toString();
}
}

View File

@@ -1,12 +0,0 @@
package com.gmail.nossr50.platform.bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock;
public class Testing18 {
Material material;
CraftBlock block;
}

View File

@@ -1,77 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import Config.Libs.Bukkit as Bukkit
// Config is located in <root>/buildSrc/src/main/java/Config.kt
// It provides a bunch of constant values we use as dependency
// strings, so we don't have to duplicate a bunch of them in
// various scripts. The import as allows for shorthand.
val bukkit: Project = Projects.bukkit!! // Static project references
val core: Project = Projects.core!! // Stored by Config.kt and created in <root>/build.gradle.kts
/* This configures ":bukkit" and it's dependent projects:
- ":bukkit:1_8_8"
- ":bukkit:1_12"
- ":bukkit:1_13"
Basically sets up all projects to depend on ":core" and
bstats-bukkit. Also sets up shadow to relocate bukkit related
packages to limit platform interference
*/
allprojects {
dependencies {
compile(core) // includes junit for tests
implementation(Bukkit.bstats) // Bukkit bstats
}
// TODO dunno if this works yet... project needs to compile.
val shadowJar by tasks.getting(ShadowJar::class) {
// Relocate bstats for bukkit, as per requirement for bstats
relocate(Shadow.Origin.bstatsBukkit, Shadow.Target.bstatsBukkit)
// Relocate the bukkit platform classes of mcmmo so we don't
// interfere with other platform classes (or core)
relocate(Deps.Groups.nossr, "${Deps.Groups.nossr}.bukkit") {
exclude("${Deps.Groups.nossr}.core")
}
}
}
// Tells all subprojects of ":bukkit" (":bukkit:1_8_8", ":bukkit:1_12",etc.)
// to depend on this project (":bukkit") to inherit the dependencies, and
// does NOT inherit the same configurations (anything configured outside
// here does not persist to child projects).
subprojects {
dependencies {
// Provide the base bukkit plugin dependency for plugin classloading.
// All "versioned" implementations will be properly classloaded by the bukkit parent
compileOnly(bukkit)
}
}
plugins {
`java-library` // This is already provided, but for static compilation,
// we declare it here so we can use the IDE static type references
}
dependencies {
// Temporary dependencies while things are being moved.
compileOnly(Bukkit.`1_13`.spigotApi) { // Spigot API for generic usage. Based on 1.13.2
isTransitive = true // We don't want the dependencies
}
compileOnly(Bukkit.`1_13`.api) { // Bukkit API for generic usage. Based on 1.13.2
isTransitive = true // We don't want the dependencies
}
compileOnly(Bukkit.`1_13`.wgCore) { // WorldGuard dependency, again, for 1.13.2
isTransitive = true // We don't want the dependencies
exclude(group = Shadow.Exclude.sk89q)
exclude(group = Shadow.Exclude.intake, module = "intake")
exclude(group = Shadow.Exclude.sk89q, module = "squirrelid")
exclude(group = Shadow.Exclude.flyway)
exclude(group = Shadow.Exclude.khelekore)
exclude(group = Shadow.Exclude.findbugs)
}
compileOnly(Bukkit.`1_13`.wgLegacy) {
isTransitive = true // We don't want the dependencies
exclude(group = Shadow.Exclude.bukkit)
exclude(group = Shadow.Exclude.sk89q, module = "commandbook")
exclude(group = Shadow.Exclude.bstats)
}
}

View File

@@ -1,12 +0,0 @@
package com.gmail.nossr50;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
public class BukkitBlockType {
private Material material;
private BlockData blockData;
}

View File

@@ -1,74 +0,0 @@
package com.gmail.nossr50;
import com.sk89q.worldedit.extension.platform.NoCapablePlatformException;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
public abstract class VersionedHandler {
private static VersionedHandler instance;
private final mcMMO plugin;
protected VersionedHandler(mcMMO plugin) {
this.plugin = plugin;
}
/**
* Gets the string value id of the BlockType, note that this is not the
* blockstate.
*
* Examples include: "minecraft:stone", "minecraft:chest", "thaumcraft:log2"
* BlockStates are more specific like "minecraft:log[variant=oak,axis=x]"
*
* This should be casting down and retrieving the id from the block registry maintained by vanilla.
*
* @param block The block instance (holds byte/numerical id or sometimes block state in newer versions)
* @return The string id of the block type
*/
public abstract String getIdFor(Block block);
/**
* Gets the string value id of the Entity, much like blocks, this is not
* the full string representation of the entity, just the string id of the
* TYPE.
*
* Examples include: "minecraft:creeeper", "minecraft:sheep", "thaumcraft:wisp"
*
* @param entity The entity instance
* @return The string id of the entity's registered type.
*/
public abstract String getIdFor(Entity entity);
// Technically can be TileEntity snapshot references as well.
public abstract String getIdFor(BlockState block);
/**
* Gets the {@link VersionedHandler} instance for this running platform.
* Note that all the handler does is perform various operations necessitated
* by either a lack of, or bridging an implementation of some API/core aspects
* that are not available through Bukkit API (like getting BlockType id's, or
* BlockState id's).
*
* @param plugin The mcmmo plugin
* @return The version handler instance
*/
public VersionedHandler getInstance(mcMMO plugin) {
if (instance == null) {
final String serverPackage = mcMMO.p.getServer().getClass().getPackage().getName();
final String serverVersion = serverPackage.substring(serverPackage.lastIndexOf(".") + 1);
try {
final Class<?> clazz = Class.forName("com.gmail.nossr50.bukkit." + serverVersion + ".NmsHandler");
if (VersionedHandler.class.isAssignableFrom(clazz)) {
instance = (VersionedHandler) clazz.getConstructor(mcMMO.class).newInstance(plugin);
}
} catch (Exception e) {
e.printStackTrace();
throw new NoCapablePlatformException("Could not discover a valid mcMMO VersionedHandler for version:" + serverVersion);
}
}
return instance;
}
}

View File

@@ -1,45 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.FlatfileDatabaseManager;
import com.gmail.nossr50.core.data.database.SQLDatabaseManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class MHDCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,325 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.skills.ModConfigType;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
public class McImportCommand implements CommandExecutor {
int fileAmount;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
importModConfig();
return true;
default:
return false;
}
}
public boolean importModConfig() {
String importFilePath = mcMMO.getModDirectory() + File.separator + "import";
File importFile = new File(importFilePath, "import.log");
mcMMO.p.getLogger().info("Starting import of mod materials...");
fileAmount = 0;
HashMap<ModConfigType, ArrayList<String>> materialNames = new HashMap<ModConfigType, ArrayList<String>>();
BufferedReader in = null;
try {
// Open the file
in = new BufferedReader(new FileReader(importFile));
String line;
String materialName;
String modName;
// While not at the end of the file
while ((line = in.readLine()) != null) {
String[] split1 = line.split("material ");
if (split1.length != 2) {
continue;
}
String[] split2 = split1[1].split(" with");
if (split2.length != 2) {
continue;
}
materialName = split2[0];
// Categorise each material under a mod config type
ModConfigType type = ModConfigType.getModConfigType(materialName);
if (!materialNames.containsKey(type)) {
materialNames.put(type, new ArrayList<String>());
}
materialNames.get(type).add(materialName);
continue;
}
} catch (FileNotFoundException e) {
mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)");
mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log");
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
tryClose(in);
}
createOutput(materialNames);
mcMMO.p.getLogger().info("Import finished! Created " + fileAmount + " files!");
return true;
}
private void createOutput(HashMap<ModConfigType, ArrayList<String>> materialNames) {
for (ModConfigType modConfigType : materialNames.keySet()) {
HashMap<String, ArrayList<String>> materialNamesType = new HashMap<String, ArrayList<String>>();
for (String materialName : materialNames.get(modConfigType)) {
String modName = Misc.getModName(materialName);
if (!materialNamesType.containsKey(modName)) {
materialNamesType.put(modName, new ArrayList<String>());
}
materialNamesType.get(modName).add(materialName);
}
createOutput(modConfigType, materialNamesType);
}
}
private void tryClose(Closeable c) {
if (c == null) {
return;
}
try {
c.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void createOutput(ModConfigType modConfigType, HashMap<String, ArrayList<String>> materialNames) {
File outputFilePath = new File(mcMMO.getModDirectory() + File.separator + "output");
if (!outputFilePath.exists() && !outputFilePath.mkdirs()) {
mcMMO.p.getLogger().severe("Could not create output directory! " + outputFilePath.getAbsolutePath());
}
FileWriter out = null;
String type = modConfigType.name().toLowerCase();
for (String modName : materialNames.keySet()) {
File outputFile = new File(outputFilePath, modName + "." + type + ".yml");
mcMMO.p.getLogger().info("Creating " + outputFile.getName());
try {
if (outputFile.exists() && !outputFile.delete()) {
mcMMO.p.getLogger().severe("Not able to delete old output file! " + outputFile.getAbsolutePath());
}
if (!outputFile.createNewFile()) {
mcMMO.p.getLogger().severe("Could not create output file! " + outputFile.getAbsolutePath());
continue;
}
StringBuilder writer = new StringBuilder();
HashMap<String, ArrayList<String>> configSections = getConfigSections(modConfigType, modName, materialNames);
if (configSections == null) {
mcMMO.p.getLogger().severe("Something went wrong!! type is " + type);
return;
}
// Write the file, go through each skill and write all the materials
for (String configSection : configSections.keySet()) {
if (configSection.equals("UNIDENTIFIED")) {
writer.append("# This isn't a valid config section and all materials in this category need to be").append("\r\n");
writer.append("# copy and pasted to a valid section of this config file.").append("\r\n");
}
writer.append(configSection).append(":").append("\r\n");
for (String line : configSections.get(configSection)) {
writer.append(line).append("\r\n");
}
writer.append("\r\n");
}
out = new FileWriter(outputFile);
out.write(writer.toString());
} catch (IOException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
} finally {
tryClose(out);
fileAmount++;
}
}
}
private HashMap<String, ArrayList<String>> getConfigSections(ModConfigType type, String modName, HashMap<String, ArrayList<String>> materialNames) {
switch (type) {
case BLOCKS:
return getConfigSectionsBlocks(modName, materialNames);
case TOOLS:
return getConfigSectionsTools(modName, materialNames);
case ARMOR:
return getConfigSectionsArmor(modName, materialNames);
case UNKNOWN:
return getConfigSectionsUnknown(modName, materialNames);
}
return null;
}
private HashMap<String, ArrayList<String>> getConfigSectionsBlocks(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>();
// Go through all the materials and categorise them under a skill
for (String materialName : materialNames.get(modName)) {
String skillName = "UNIDENTIFIED";
if (materialName.contains("ORE")) {
skillName = "Mining";
} else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting";
} else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism";
} else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
skillName = "Excavation";
}
if (!configSections.containsKey(skillName)) {
configSections.put(skillName, new ArrayList<String>());
}
ArrayList<String> skillContents = configSections.get(skillName);
skillContents.add(" " + materialName + "|0:");
skillContents.add(" " + " " + "XP_Gain: 99");
skillContents.add(" " + " " + "Double_Drops_Enabled: true");
if (skillName.equals("Mining")) {
skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
} else if (skillName.equals("Woodcutting")) {
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
}
}
return configSections;
}
private HashMap<String, ArrayList<String>> getConfigSectionsTools(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>();
// Go through all the materials and categorise them under a tool type
for (String materialName : materialNames.get(modName)) {
String toolType = "UNIDENTIFIED";
if (materialName.contains("PICKAXE")) {
toolType = "Pickaxes";
} else if (materialName.contains("AXE")) {
toolType = "Axes";
} else if (materialName.contains("BOW")) {
toolType = "Bows";
} else if (materialName.contains("HOE")) {
toolType = "Hoes";
} else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
toolType = "Shovels";
} else if (materialName.contains("SWORD")) {
toolType = "Swords";
}
if (!configSections.containsKey(toolType)) {
configSections.put(toolType, new ArrayList<String>());
}
ArrayList<String> skillContents = configSections.get(toolType);
skillContents.add(" " + materialName + ":");
skillContents.add(" " + " " + "XP_Modifier: 1.0");
skillContents.add(" " + " " + "Tier: 1");
skillContents.add(" " + " " + "Ability_Enabled: true");
addRepairableLines(materialName, skillContents);
}
return configSections;
}
private HashMap<String, ArrayList<String>> getConfigSectionsArmor(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>();
// Go through all the materials and categorise them under an armor type
for (String materialName : materialNames.get(modName)) {
String toolType = "UNIDENTIFIED";
if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
toolType = "Boots";
} else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
toolType = "Chestplates";
} else if (materialName.contains("HELM") || materialName.contains("HAT")) {
toolType = "Helmets";
} else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
toolType = "Leggings";
}
if (!configSections.containsKey(toolType)) {
configSections.put(toolType, new ArrayList<String>());
}
ArrayList<String> skillContents = configSections.get(toolType);
skillContents.add(" " + materialName + ":");
addRepairableLines(materialName, skillContents);
}
return configSections;
}
private void addRepairableLines(String materialName, ArrayList<String> skillContents) {
skillContents.add(" " + " " + "Repairable: true");
skillContents.add(" " + " " + "Repair_Material: REPAIR_MATERIAL_NAME");
skillContents.add(" " + " " + "Repair_Material_Data_Value: 0");
skillContents.add(" " + " " + "Repair_Material_Quantity: 9");
skillContents.add(" " + " " + "Repair_Material_Pretty_Name: Repair Item Name");
skillContents.add(" " + " " + "Repair_MinimumLevel: 0");
skillContents.add(" " + " " + "Repair_XpMultiplier: 1.0");
Material material = Material.matchMaterial(materialName);
short durability = (material == null) ? (short) 9999 : material.getMaxDurability();
skillContents.add(" " + " " + "Durability: " + ((durability > 0) ? durability : (short) 9999));
}
private HashMap<String, ArrayList<String>> getConfigSectionsUnknown(String modName, HashMap<String, ArrayList<String>> materialNames) {
HashMap<String, ArrayList<String>> configSections = new HashMap<String, ArrayList<String>>();
// Go through all the materials and print them
for (String materialName : materialNames.get(modName)) {
String configKey = "UNIDENTIFIED";
if (!configSections.containsKey(configKey)) {
configSections.put(configKey, new ArrayList<String>());
}
ArrayList<String> skillContents = configSections.get(configKey);
skillContents.add(" " + materialName);
}
return configSections;
}
}

View File

@@ -1,29 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McabilityCommand extends ToggleCommand {
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcabilityOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcability(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
mcMMOPlayer.toggleAbilityUse();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
}
}

View File

@@ -1,90 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.datatypes.database.DatabaseType;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class McconvertCommand implements TabExecutor {
private static final List<String> FORMULA_TYPES;
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
static {
ArrayList<String> formulaTypes = new ArrayList<String>();
ArrayList<String> databaseTypes = new ArrayList<String>();
for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString());
}
for (DatabaseType type : DatabaseType.values()) {
databaseTypes.add(type.toString());
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM.toString());
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
}
Collections.sort(formulaTypes);
Collections.sort(databaseTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
}
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args);
} else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args);
}
return false;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], SUBCOMMANDS, new ArrayList<String>(SUBCOMMANDS.size()));
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return StringUtil.copyPartialMatches(args[0], DATABASE_TYPES, new ArrayList<String>(DATABASE_TYPES.size()));
}
if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[0].equalsIgnoreCase("exp")) {
return StringUtil.copyPartialMatches(args[0], FORMULA_TYPES, new ArrayList<String>(FORMULA_TYPES.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
}

View File

@@ -1,29 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McgodCommand extends ToggleCommand {
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcgodOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcgod(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName));
}
}

View File

@@ -1,115 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class McmmoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (!Permissions.mcmmoDescription(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
String description = LocaleLoader.getString("mcMMO.Description");
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);
if (MainConfig.getInstance().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "com.gmail.nossr50@com.gmail.com" + ChatColor.GOLD + " Paypal");
}
if (Permissions.showversion(sender)) {
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
}
mcMMO.getHolidayManager().anniversaryCheck(sender);
return true;
case 1:
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
if (!Permissions.mcmmoHelp(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
displayGeneralCommands(sender);
displayOtherCommands(sender);
displayPartyCommands(sender);
}
return true;
default:
return false;
}
}
private void displayGeneralCommands(CommandSender sender) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage(ChatColor.DARK_AQUA + " /<skill>" + LocaleLoader.getString("Commands.SkillInfo"));
sender.sendMessage(ChatColor.DARK_AQUA + " /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.inspect(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mcability(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
}
private void displayOtherCommands(CommandSender sender) {
//Don't show them this category if they have none of the permissions
if (!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender))
return;
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
if (Permissions.skillreset(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
if (Permissions.mmoedit(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (Permissions.adminChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.mcgod(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /mcgod " + LocaleLoader.getString("Commands.mcgod"));
}
}
private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party quit " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.partyChat(sender)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
}
sender.sendMessage(ChatColor.DARK_AQUA + " /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage(ChatColor.DARK_AQUA + " /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage(ChatColor.DARK_AQUA + " /party teleport <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
}
}

View File

@@ -1,34 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class McnotifyCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
sender.sendMessage(LocaleLoader.getString("Commands.Notifications." + (mcMMOPlayer.useChatNotifications() ? "Off" : "On")));
mcMMOPlayer.toggleChatNotifications();
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,33 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McrefreshCommand extends ToggleCommand {
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.mcrefreshOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.mcrefresh(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetAbilityMode();
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
}
}

View File

@@ -1,88 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class McscoreboardCommand implements TabExecutor {
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
ScoreboardManager.clearBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
return true;
}
if (args[0].equalsIgnoreCase("keep")) {
if (!MainConfig.getInstance().getAllowKeepBoard() || !MainConfig.getInstance().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
return true;
}
return help(sender);
case 2:
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
return true;
}
return help(sender);
default:
return help(sender);
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
default:
return ImmutableList.of();
}
}
private boolean help(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
return true;
}
}

View File

@@ -1,80 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public abstract class ToggleCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!hasSelfPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
applyCommandAction(UserManager.getPlayer(sender.getName()));
return true;
case 1:
if (!hasOtherPermission(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true;
}
if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
return true;
}
applyCommandAction(mcMMOPlayer);
sendSuccessMessage(sender, playerName);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
}
}
protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
}

View File

@@ -1,117 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.player.NotificationManager;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class XprateCommand implements TabExecutor {
private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (!args[0].equalsIgnoreCase("reset") && !args[0].equalsIgnoreCase("clear")) {
return false;
}
if (!Permissions.xprateReset(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (mcMMO.p.isXPEventEnabled()) {
if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"),
LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
10, 10 * 20, 20);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
mcMMO.p.toggleXpEventEnabled();
}
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(ORIGINAL_XP_RATE);
return true;
case 2:
if (CommandUtils.isInvalidInteger(sender, args[0])) {
return true;
}
if (!Permissions.xprateSet(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (CommandUtils.shouldDisableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(false);
} else if (CommandUtils.shouldEnableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(true);
} else {
return false;
}
int newXpRate = Integer.parseInt(args[0]);
if (newXpRate < 0) {
sender.sendMessage(ChatColor.RED + LocaleLoader.getString("Commands.NegativeNumberWarn"));
return true;
}
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) {
if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"),
LocaleLoader.getString("Commands.Event.XP", newXpRate),
10, 10 * 20, 20);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
if (StringUtils.isInt(args[0])) {
return ImmutableList.of();
}
return StringUtil.copyPartialMatches(args[0], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
default:
return ImmutableList.of();
}
}
}

View File

@@ -1,15 +0,0 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import org.bukkit.command.CommandSender;
public class AdminChatCommand extends ChatCommand {
public AdminChatCommand() {
super(ChatMode.ADMIN);
}
@Override
protected void handleChatSending(CommandSender sender, String[] args) {
chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0));
}
}

View File

@@ -1,139 +0,0 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.core.chat.ChatManager;
import com.gmail.nossr50.core.chat.ChatManagerFactory;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public abstract class ChatCommand implements TabExecutor {
protected ChatManager chatManager;
private ChatMode chatMode;
public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode;
this.chatManager = ChatManagerFactory.getChatManager(mcMMO.p, chatMode);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
} else {
enableChatMode(mcMMOPlayer, sender);
}
return true;
case 1:
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
enableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
}
if (CommandUtils.shouldDisableToggle(args[0])) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
disableChatMode(UserManager.getPlayer(sender.getName()), sender);
return true;
}
// Fallthrough
default:
handleChatSending(sender, args);
return true;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
default:
return ImmutableList.of();
}
}
protected String buildChatMessage(String[] args, int index) {
StringBuilder builder = new StringBuilder();
builder.append(args[index]);
for (int i = index + 1; i < args.length; i++) {
builder.append(" ");
builder.append(args[i]);
}
return builder.toString();
}
protected String getDisplayName(CommandSender sender) {
return (sender instanceof Player) ? ((Player) sender).getDisplayName() : LocaleLoader.getString("Commands.Chat.Console");
}
protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return;
}
mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage());
}
private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage());
}
}

View File

@@ -1,30 +0,0 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.ToggleCommand;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McChatSpy extends ToggleCommand {
@Override
protected boolean hasOtherPermission(CommandSender sender) {
return Permissions.adminChatSpyOthers(sender);
}
@Override
protected boolean hasSelfPermission(CommandSender sender) {
return Permissions.adminChatSpy(sender);
}
@Override
protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.AdminChatSpy." + (mcMMOPlayer.isPartyChatSpying() ? "Disabled" : "Enabled")));
mcMMOPlayer.togglePartyChatSpying();
}
@Override
protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Toggle", playerName));
}
}

View File

@@ -1,57 +0,0 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.core.chat.PartyChatManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyChatCommand extends ChatCommand {
public PartyChatCommand() {
super(ChatMode.PARTY);
}
@Override
protected void handleChatSending(CommandSender sender, String[] args) {
Party party;
String message;
if (sender instanceof Player) {
party = UserManager.getPlayer((Player) sender).getParty();
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return;
}
message = buildChatMessage(args, 0);
} else {
if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return;
}
party = PartyManager.getParty(args[0]);
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return;
}
message = buildChatMessage(args, 1);
}
((PartyChatManager) chatManager).setParty(party);
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
}
}

View File

@@ -1,73 +0,0 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.datatypes.database.DatabaseType;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ConvertDatabaseCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType);
if (previousType == DatabaseType.CUSTOM) {
Class<?> clazz;
try {
clazz = Class.forName(args[1]);
if (!DatabaseManager.class.isAssignableFrom(clazz)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
} catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
PlayerProfile profile = oldDatabase.loadPlayerProfile(player.getUniqueId());
if (profile.isLoaded()) {
mcMMO.getDatabaseManager().saveUser(profile);
}
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
new DatabaseConversionTask(oldDatabase, sender, previousType.toString(), newType.toString()).runTaskAsynchronously(mcMMO.p);
return true;
default:
return false;
}
}
}

View File

@@ -1,36 +0,0 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class McpurgeCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (MainConfig.getInstance().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers();
}
sender.sendMessage(LocaleLoader.getString("Commands.mcpurge.Success"));
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,50 +0,0 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class McremoveCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
if (UserManager.getOfflinePlayer(playerName) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
return true;
}
if (mcMMO.getDatabaseManager().removeUser(playerName)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
} else {
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
}
}
}

View File

@@ -1,37 +0,0 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import java.util.List;
public class MmoshowdbCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (MainConfig.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,45 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AddlevelsCommand extends ExperienceCommand {
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.addlevels(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.addlevelsOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
}
}

View File

@@ -1,43 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.experience.XPGainSource;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AddxpCommand extends ExperienceCommand {
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.addxp(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.addxpOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (player != null) {
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} else {
profile.addXp(skill, value);
profile.scheduleAsyncSave();
}
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
}
}

View File

@@ -1,49 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ConvertExperienceCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
FormulaType previousType = mcMMO.getFormulaManager().getPreviousFormulaType();
FormulaType newType = FormulaType.getFormulaType(args[1].toUpperCase());
if (newType == FormulaType.UNKNOWN) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Invalid"));
return true;
}
if (previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Same", newType.toString()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Experience.Start", previousType.toString(), newType.toString()));
UserManager.saveAll();
UserManager.clearAll();
new FormulaConversionTask(sender, newType).runTaskLater(mcMMO.p, 1);
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
return true;
default:
return false;
}
}
}

View File

@@ -1,160 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public abstract class ExperienceCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill;
switch (args.length) {
case 2:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[0], args[1])) {
return true;
}
skill = PrimarySkillType.getSkill(args[0]);
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
if (skill != null && skill.isChildSkill()) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
return true;
case 3:
if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[1], args[2])) {
return true;
}
skill = PrimarySkillType.getSkill(args[1]);
if (args[1].equalsIgnoreCase("all")) {
skill = null;
}
if (skill != null && skill.isChildSkill()) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
editValues(null, profile, skill, value);
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
}
handleSenderMessage(sender, playerName, skill);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType, value);
}
if (player != null) {
handlePlayerMessageAll(player, value);
}
} else {
handleCommand(player, profile, skill, value);
if (player != null) {
handlePlayerMessageSkill(player, value, skill);
}
}
}
}

View File

@@ -1,51 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class MmoeditCommand extends ExperienceCommand {
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.mmoedit(sender);
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.mmoeditOthers(sender);
}
@Override
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
if (value == skillLevel) {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND);
}
@Override
protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
}
@Override
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
}
}

View File

@@ -1,174 +0,0 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* This class mirrors the structure of ExperienceCommand, except the
* value/quantity argument is removed.
*/
public class SkillresetCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill;
switch (args.length) {
case 1:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!permissionsCheckSelf(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[0])) {
return true;
}
if (args[0].equalsIgnoreCase("all")) {
skill = null;
} else {
skill = PrimarySkillType.getSkill(args[1]);
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
return true;
case 2:
if (!permissionsCheckOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!validateArguments(sender, args[1])) {
return true;
}
if (args[1].equalsIgnoreCase("all")) {
skill = null;
} else {
skill = PrimarySkillType.getSkill(args[1]);
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
UUID uuid = null;
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
if (player != null) {
uuid = player.getUniqueId();
}
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
if (CommandUtils.unloadedProfile(sender, profile)) {
return true;
}
editValues(null, profile, skill);
} else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
}
handleSenderMessage(sender, playerName, skill);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill) {
int levelsRemoved = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, 0);
if (player == null) {
profile.scheduleAsyncSave();
return;
}
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false, XPGainReason.COMMAND);
}
protected boolean permissionsCheckSelf(CommandSender sender) {
return Permissions.skillreset(sender);
}
protected boolean permissionsCheckOthers(CommandSender sender) {
return Permissions.skillresetOthers(sender);
}
protected void handlePlayerMessageAll(Player player) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
protected void handlePlayerMessageSkill(Player player, PrimarySkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
}
private boolean validateArguments(CommandSender sender, String skillName) {
return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
handleCommand(player, profile, primarySkillType);
}
if (player != null) {
handlePlayerMessageAll(player);
}
} else {
handleCommand(player, profile, skill);
if (player != null) {
handlePlayerMessageSkill(player, skill);
}
}
}
}

View File

@@ -1,63 +0,0 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.hardcoreToggle(sender);
}
@Override
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender);
}
@Override
protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreStatLossEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreStatLossEnabled();
}
@Override
protected void enable(PrimarySkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(PrimarySkillType skill) {
toggle(false, skill);
}
@Override
protected void modify(CommandSender sender, double newPercentage) {
MainConfig.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreStatLossEnabled(enable);
}
} else {
skill.setHardcoreStatLossEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
}
}

View File

@@ -1,134 +0,0 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public abstract class HardcoreModeCommand implements TabExecutor {
protected final DecimalFormat percent = new DecimalFormat("##0.00%");
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (!checkTogglePermissions(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (checkEnabled(null)) {
disable(null);
} else {
enable(null);
}
return true;
case 1:
if (CommandUtils.shouldEnableToggle(args[0])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(null);
return true;
}
if (CommandUtils.shouldDisableToggle(args[0])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
disable(null);
return true;
}
if (CommandUtils.isInvalidDouble(sender, args[0])) {
return true;
}
if (!Permissions.hardcoreModify(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
modify(sender, Double.parseDouble(args[0]));
return true;
case 2:
if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true;
}
PrimarySkillType skill = PrimarySkillType.getSkill(args[0]);
if (!CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
if (CommandUtils.shouldDisableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
if (StringUtils.isDouble(args[0])) {
return ImmutableList.of();
}
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
default:
return ImmutableList.of();
}
}
protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(PrimarySkillType skill);
protected abstract void enable(PrimarySkillType skill);
protected abstract void disable(PrimarySkillType skill);
protected abstract void modify(CommandSender sender, double newPercentage);
}

View File

@@ -1,63 +0,0 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender;
public class VampirismCommand extends HardcoreModeCommand {
@Override
protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender);
}
@Override
protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender);
}
@Override
protected boolean checkEnabled(PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {
if (!primarySkillType.getHardcoreVampirismEnabled()) {
return false;
}
}
return true;
}
return skill.getHardcoreVampirismEnabled();
}
@Override
protected void enable(PrimarySkillType skill) {
toggle(true, skill);
}
@Override
protected void disable(PrimarySkillType skill) {
toggle(false, skill);
}
@Override
protected void modify(CommandSender sender, double newPercentage) {
MainConfig.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
private void toggle(boolean enable, PrimarySkillType skill) {
if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreVampirismEnabled(enable);
}
} else {
skill.setHardcoreVampirismEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
}
}

View File

@@ -1,236 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class PartyCommand implements TabExecutor {
private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
static {
ArrayList<String> subcommands = new ArrayList<String>();
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
subcommands.add(subcommand.toString());
}
Collections.sort(subcommands);
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
}
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
private CommandExecutor partyKickCommand = new PartyKickCommand();
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
private CommandExecutor partyTeleportCommand = new PtpCommand();
private CommandExecutor partyChatCommand = new PartyChatCommand();
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!Permissions.party(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
Player player = (Player) sender;
if (!UserManager.hasPlayerDataKey(player)) {
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player);
}
return partyInfoCommand.onCommand(sender, command, label, args);
}
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return printUsage(player);
}
// Can't use this for lock/unlock since they're handled by the same command
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (subcommand) {
case JOIN:
return partyJoinCommand.onCommand(sender, command, label, args);
case ACCEPT:
return partyAcceptCommand.onCommand(sender, command, label, args);
case CREATE:
return partyCreateCommand.onCommand(sender, command, label, args);
case HELP:
return partyHelpCommand.onCommand(sender, command, label, args);
default:
break;
}
// Party member commands
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(player);
}
switch (subcommand) {
case INFO:
return partyInfoCommand.onCommand(sender, command, label, args);
case QUIT:
return partyQuitCommand.onCommand(sender, command, label, args);
case INVITE:
return partyInviteCommand.onCommand(sender, command, label, args);
case TELEPORT:
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
case CHAT:
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
default:
break;
}
// Party leader commands
if (!mcMMOPlayer.getParty().getLeader().getUniqueId().equals(player.getUniqueId())) {
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
switch (subcommand) {
case XPSHARE:
return partyXpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE:
return partyItemShareCommand.onCommand(sender, command, label, args);
case KICK:
return partyKickCommand.onCommand(sender, command, label, args);
case DISBAND:
return partyDisbandCommand.onCommand(sender, command, label, args);
case OWNER:
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
case LOCK:
case UNLOCK:
return partyLockCommand.onCommand(sender, command, label, args);
case PASSWORD:
return partyChangePasswordCommand.onCommand(sender, command, label, args);
case RENAME:
return partyRenameCommand.onCommand(sender, command, label, args);
case ALLIANCE:
return partyAllianceCommand.onCommand(sender, command, label, args);
default:
break;
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], PARTY_SUBCOMMANDS, new ArrayList<String>(PARTY_SUBCOMMANDS.size()));
case 2:
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return ImmutableList.of();
}
switch (subcommand) {
case JOIN:
case INVITE:
case KICK:
case OWNER:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
case XPSHARE:
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<String>(XPSHARE_COMPLETIONS.size()));
case ITEMSHARE:
return StringUtil.copyPartialMatches(args[1], ITEMSHARE_COMPLETIONS, new ArrayList<String>(ITEMSHARE_COMPLETIONS.size()));
case LOCK:
case CHAT:
return StringUtil.copyPartialMatches(args[1], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
case PASSWORD:
return StringUtil.copyPartialMatches(args[1], CommandUtils.RESET_OPTIONS, new ArrayList<String>(CommandUtils.RESET_OPTIONS.size()));
case TELEPORT:
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<String>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Player player = (Player) sender;
Party party = UserManager.getPlayer(player).getParty();
playerNames = party.getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<String>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
case 3:
if (PartySubcommandType.getSubcommand(args[0]) == PartySubcommandType.ITEMSHARE && isItemShareCategory(args[1])) {
return StringUtil.copyPartialMatches(args[2], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<String>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
}
return ImmutableList.of();
default:
return ImmutableList.of();
}
}
private boolean printUsage(Player player) {
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));
return true;
}
private String[] extractArgs(String[] args) {
return Arrays.copyOfRange(args, 1, args.length);
}
private boolean isItemShareCategory(String category) {
return category.equalsIgnoreCase("loot") || category.equalsIgnoreCase("mining") || category.equalsIgnoreCase("herbalism") || category.equalsIgnoreCase("woodcutting") || category.equalsIgnoreCase("misc");
}
}

View File

@@ -1,128 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class PartyInfoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
case 1:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
displayPartyHeader(player, party);
displayShareModeInfo(player, party);
displayPartyFeatures(player, party);
displayMemberInfo(player, mcMMOPlayer, party);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
return true;
}
}
private void displayPartyHeader(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
StringBuilder status = new StringBuilder();
status.append(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()));
if (!party.hasReachedLevelCap()) {
status.append(" (").append(party.getXpToLevelPercentage()).append(")");
}
player.sendMessage(status.toString());
}
private void displayPartyFeatures(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Features.Header"));
List<String> unlockedPartyFeatures = new ArrayList<String>();
List<String> lockedPartyFeatures = new ArrayList<String>();
for (PartyFeature partyFeature : PartyFeature.values()) {
if (!partyFeature.hasPermission(player)) {
continue;
}
if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(partyFeature.getLocaleString());
} else {
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
}
}
player.sendMessage(LocaleLoader.getString("Commands.Party.UnlockedFeatures", unlockedPartyFeatures.isEmpty() ? "None" : unlockedPartyFeatures));
for (String message : lockedPartyFeatures) {
player.sendMessage(message);
}
}
private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) {
return party.getLevel() >= MainConfig.getInstance().getPartyFeatureUnlockLevel(partyFeature);
}
private void displayShareModeInfo(Player player, Party party) {
boolean xpShareEnabled = isUnlockedFeature(party, PartyFeature.XP_SHARE);
boolean itemShareEnabled = isUnlockedFeature(party, PartyFeature.ITEM_SHARE);
boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) {
return;
}
String expShareInfo = "";
String itemShareInfo = "";
String separator = "";
if (xpShareEnabled) {
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
}
if (itemShareEnabled) {
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
}
if (xpShareEnabled && itemShareEnabled) {
separator = ChatColor.DARK_GRAY + " || ";
}
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
if (itemSharingActive) {
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
}
}
private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
/*
* Only show members of the party that this member can see
*/
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size() + 1, membersOnline));
player.sendMessage(party.createMembersList(player));
}
}

View File

@@ -1,85 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.ItemShareType;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyItemShareCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
return true;
}
switch (args.length) {
case 2:
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
if (mode == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
return true;
}
handleChangingShareMode(party, mode);
return true;
case 3:
boolean toggle;
if (CommandUtils.shouldEnableToggle(args[2])) {
toggle = true;
} else if (CommandUtils.shouldDisableToggle(args[2])) {
toggle = false;
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}
try {
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
}
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}
}
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setItemShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}
private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
party.setSharingDrops(type, toggle);
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : party.getOnlineMembers()) {
member.sendMessage(toggleMessage);
}
}
}

View File

@@ -1,79 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyJoinCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true;
}
Player target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return true;
}
String password = getPassword(args);
// Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
return true;
}
String partyName = targetParty.getName();
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
return true;
}
if (PartyManager.isPartyFull(player, targetParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "join", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]"));
return true;
}
}
private String getPassword(String[] args) {
if (args.length == 3) {
return args[2];
}
return null;
}
}

View File

@@ -1,69 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyLockCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("lock")) {
togglePartyLock(sender, true);
} else if (args[0].equalsIgnoreCase("unlock")) {
togglePartyLock(sender, false);
}
return true;
case 2:
if (!args[0].equalsIgnoreCase("lock")) {
sendUsageStrings(sender);
return true;
}
if (CommandUtils.shouldEnableToggle(args[1])) {
togglePartyLock(sender, true);
} else if (CommandUtils.shouldDisableToggle(args[1])) {
togglePartyLock(sender, false);
} else {
sendUsageStrings(sender);
}
return true;
default:
sendUsageStrings(sender);
return true;
}
}
private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
}
private void togglePartyLock(CommandSender sender, boolean lock) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
if (lock ? party.isLocked() : !party.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return;
}
party.setLocked(lock);
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
}
}

View File

@@ -1,53 +0,0 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyXpShareCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));
return true;
}
switch (args.length) {
case 2:
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.NONE);
} else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.EQUAL);
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
}
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
return true;
}
}
private void handleChangingShareMode(Party party, ShareMode mode) {
party.setXpShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Xp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage);
}
}
}

View File

@@ -1,38 +0,0 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceAcceptCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.hasPartyAllianceInvite()) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoInvites"));
return true;
}
if (mcMMOPlayer.getParty().getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
PartyManager.acceptAllianceInvite(mcMMOPlayer);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
return true;
}
}
}

View File

@@ -1,131 +0,0 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class PartyAllianceCommand implements TabExecutor {
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private Player player;
private Party playerParty;
private Party targetParty;
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
switch (args.length) {
case 1:
if (playerParty.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}
if (playerParty.getAlly() == null) {
printUsage();
return true;
}
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
return true;
case 2:
case 3:
if (playerParty.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}
if (args[1].equalsIgnoreCase("invite")) {
return partyAllianceInviteCommand.onCommand(sender, command, label, args);
}
if (args[1].equalsIgnoreCase("accept")) {
return partyAllianceAcceptCommand.onCommand(sender, command, label, args);
}
if (args[1].equalsIgnoreCase("disband")) {
return partyAllianceDisbandCommand.onCommand(sender, command, label, args);
}
if (playerParty.getAlly() == null) {
printUsage();
return true;
}
targetParty = playerParty.getAlly();
displayPartyHeader();
displayMemberInfo(mcMMOPlayer);
return true;
default:
return false;
}
}
private boolean printUsage() {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.0"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Help.1"));
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], ALLIANCE_SUBCOMMANDS, new ArrayList<String>(ALLIANCE_SUBCOMMANDS.size()));
if (matches.size() == 0) {
List<String> playerNames = CommandUtils.getOnlinePlayerNames(commandSender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
private void displayPartyHeader() {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Ally", playerParty.getName(), targetParty.getName()));
}
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
player.sendMessage(playerParty.createMembersList(player));
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
player.sendMessage(targetParty.createMembersList(player));
}
}

View File

@@ -1,35 +0,0 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceDisbandCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party party = mcMMOPlayer.getParty();
if (party.getAlly() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.None"));
return true;
}
PartyManager.disbandAlliance(player, party, party.getAlly());
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
return true;
}
}
}

View File

@@ -1,70 +0,0 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PartyAllianceInviteCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 3:
String targetName = CommandUtils.getMatchedPlayerName(args[2]);
McMMOPlayer mcMMOTarget = UserManager.getOfflinePlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true;
}
if (!mcMMOTarget.inParty()) {
player.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
return true;
}
if (!mcMMOTarget.getParty().getLeader().getUniqueId().equals(target.getUniqueId())) {
player.sendMessage(LocaleLoader.getString("Party.Target.NotOwner", targetName));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (playerParty.getAlly() != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.AlreadyAllies"));
return true;
}
mcMMOTarget.setPartyAllianceInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.0", playerParty.getName(), playerName));
target.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Invite.1"));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.3", "party", "alliance", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@@ -1,30 +0,0 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PtpAcceptAnyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportAcceptAll(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
}
ptpRecord.toggleConfirmRequired();
return true;
}
}

View File

@@ -1,62 +0,0 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PtpAcceptCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportAccept(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
Player player = (Player) sender;
PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
return true;
}
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), MainConfig.getInstance().getPTPCommandTimeout())) {
ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true;
}
Player target = ptpRecord.getRequestor();
ptpRecord.removeRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
return true;
}
if (MainConfig.getInstance().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();
if (!Permissions.partyTeleportAllWorlds(target)) {
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true;
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true;
}
}
}
PtpCommand.handleTeleportWarmup(target, player);
return true;
}
}

View File

@@ -1,221 +0,0 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class PtpCommand implements TabExecutor {
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
if (!target.isValid()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = MainConfig.getInstance().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
} else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return true;
}
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true;
if (!UserManager.hasPlayerDataKey(player)) {
return true;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
Party party = mcMMOPlayer.getParty();
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
return true;
}
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("toggle")) {
return ptpToggleCommand.onCommand(sender, command, label, args);
}
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
return ptpAcceptAnyCommand.onCommand(sender, command, label, args);
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = MainConfig.getInstance().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return true;
}
}
if (args[0].equalsIgnoreCase("accept")) {
return ptpAcceptCommand.onCommand(sender, command, label, args);
}
if (!Permissions.partyTeleportSend(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
int ptpCooldown = MainConfig.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0]));
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> matches = StringUtil.copyPartialMatches(args[0], TELEPORT_SUBCOMMANDS, new ArrayList<String>(TELEPORT_SUBCOMMANDS.size()));
if (matches.size() == 0) {
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.inParty()) {
return ImmutableList.of();
}
List<String> playerNames = mcMMOPlayer.getParty().getOnlinePlayerNames(player);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
}
return matches;
default:
return ImmutableList.of();
}
}
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
if (!canTeleport(sender, player, targetName)) {
return;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();
if (!ptpRecord.isConfirmRequired()) {
handleTeleportWarmup(player, target);
return;
}
ptpRecord.setRequestor(player);
ptpRecord.actualizeTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", MainConfig.getInstance().getPTPCommandTimeout()));
}
}

View File

@@ -1,30 +0,0 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class PtpToggleCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.partyTeleportToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
}
ptpRecord.toggleEnabled();
return true;
}
}

View File

@@ -1,112 +0,0 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class InspectCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
if (!CommandUtils.isLoaded(sender, profile)) {
return true;
}
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
return true;
}
if (MainConfig.getInstance().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!MainConfig.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (PrimarySkillType skill : PrimarySkillType.GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (PrimarySkillType skill : PrimarySkillType.COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (PrimarySkillType skill : PrimarySkillType.MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
} else {
Player target = mcMMOPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
if (!Permissions.inspectOffline(sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
} else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true;
}
if (MainConfig.getInstance().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!MainConfig.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
CommandUtils.printGatheringSkills(target, sender);
CommandUtils.printCombatSkills(target, sender);
CommandUtils.printMiscSkills(target, sender);
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
}
}
}

View File

@@ -1,71 +0,0 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class MccooldownCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!MainConfig.getInstance().getCooldownUseChat()) {
return true;
}
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (SuperAbilityType ability : SuperAbilityType.values()) {
if (!ability.getPermissions(player)) {
continue;
}
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
} else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
}
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,112 +0,0 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class McrankCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!Permissions.mcrank(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
display(sender, sender.getName());
return true;
case 1:
if (!Permissions.mcrankOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
if (mcMMOPlayer != null) {
Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true;
}
} else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
return true;
}
display(sender, playerName);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
}
}
private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return;
}
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return;
} else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
}
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = MainConfig.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard());
boolean useChat = !useBoard || MainConfig.getInstance().getRankUseChat();
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}
}

View File

@@ -1,65 +0,0 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.List;
public class McstatsCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (MainConfig.getInstance().getStatsUseBoard() && MainConfig.getInstance().getScoreboardsEnabled()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!MainConfig.getInstance().getStatsUseChat()) {
return true;
}
}
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
CommandUtils.printGatheringSkills(player);
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = MainConfig.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
} else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -1,135 +0,0 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class MctopCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill = null;
switch (args.length) {
case 0:
display(1, skill, sender, command);
return true;
case 1:
if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
return true;
}
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(1, skill, sender, command);
return true;
case 2:
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SKILL_NAMES, new ArrayList<String>(PrimarySkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
private void display(int page, PrimarySkillType skill, CommandSender sender, Command command) {
if (skill != null && !Permissions.mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (sender instanceof Player) {
if (!CommandUtils.hasPlayerDataKey(sender)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;
if (seconds < 1) {
seconds = 1;
}
sender.sendMessage(LocaleLoader.formatString(LocaleLoader.getString("Commands.Database.Cooldown"), seconds));
return;
}
if (((Player) sender).hasMetadata(mcMMO.databaseCommandKey)) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Processing"));
return;
} else {
((Player) sender).setMetadata(mcMMO.databaseCommandKey, new FixedMetadataValue(mcMMO.p, null));
}
mcMMOPlayer.actualizeDatabaseATS();
}
display(page, skill, sender);
}
private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (MainConfig.getInstance().getTopUseBoard());
boolean useChat = !useBoard || MainConfig.getInstance().getTopUseChat();
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) {
return null;
}
PrimarySkillType skill = PrimarySkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) {
return null;
}
return skill;
}
}

View File

@@ -1,15 +0,0 @@
package com.gmail.nossr50.commands.server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/**
* This command facilitates switching the skill system scale between classic and modern scale
*/
public class Mcmmoupgrade implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}

View File

@@ -1,98 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.random.RandomChanceSkill;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.gmail.nossr50.listeners.InteractionManager;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String dodgeChanceLucky;
private boolean canDodge;
private boolean canRoll;
public AcrobaticsCommand() {
super(PrimarySkillType.ACROBATICS);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// ACROBATICS_DODGE
if (canDodge) {
String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_DODGE);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE);
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canDodge) {
messages.add(getStatMessage(SubSkillType.ACROBATICS_DODGE, dodgeChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
}
if (canRoll) {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if (abstractSubSkill != null) {
double rollChance, graceChance;
//Chance to roll at half
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
//Chance to graceful roll
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
//Chance Stat Calculations
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
String rollStrings[] = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
//Format
double rollChanceLucky = rollChance * 1.333D;
double graceChanceLucky = graceChance * 1.333D;
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));
/*messages.add(getStatMessage(true, false, SubSkillType.ACROBATICS_ROLL, String.valueOf(graceChance))
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", String.valueOf(graceChanceLucky)) : ""));*/
}
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ACROBATICS);
return textComponents;
}
}

View File

@@ -1,96 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyManager;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AlchemyCommand extends SkillCommand {
private String brewSpeed;
private String brewSpeedLucky;
private int tier;
private int ingredientCount;
private String ingredientList;
private boolean canCatalysis;
private boolean canConcoctions;
public AlchemyCommand() {
super(PrimarySkillType.ALCHEMY);
}
protected String[] calculateAbilityDisplayValues(Player player) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
return displayValues;
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// ALCHEMY_CATALYSIS
if (canCatalysis) {
String[] catalysisStrings = calculateAbilityDisplayValues(player);
brewSpeed = catalysisStrings[0];
brewSpeedLucky = catalysisStrings[1];
}
// ALCHEMY_CONCOCTIONS
if (canConcoctions) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
tier = alchemyManager.getTier();
ingredientCount = alchemyManager.getIngredients().size();
ingredientList = alchemyManager.getIngredientList();
}
}
@Override
protected void permissionsCheck(Player player) {
canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canCatalysis) {
messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : ""));
}
if (canConcoctions) {
messages.add(getStatMessage(false, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(tier), String.valueOf(RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS))));
messages.add(getStatMessage(true, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(ingredientCount), ingredientList));
//messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS)));
//messages.add(LocaleLoader.getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
return textComponents;
}
}

View File

@@ -1,202 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public class AprilCommand implements TabExecutor {
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
skillName = StringUtils.getCapitalized(label);
switch (args.length) {
case 0:
Player player = (Player) sender;
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
float skillValue = Misc.getRandom().nextInt(99);
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
List<String> effectMessages = effectsDisplay(fakeSkillType);
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
for (String message : effectMessages) {
player.sendMessage(message);
}
}
List<String> statsMessages = statsDisplay(fakeSkillType);
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
return true;
default:
return true;
}
}
private String getXPGainString(FakeSkillType fakeSkillType) {
switch (fakeSkillType) {
case MACHO:
return "Get beaten up";
case JUMPING:
return "Kris Kross will make ya Jump Jump";
case THROWING:
return "Chuck your items on the floor";
case WRECKING:
return "I'M GONNA WRECK IT!";
case CRAFTING:
return "Craft apple pies";
case WALKING:
return "Walk around the park";
case SWIMMING:
return "Like a fish on a bicycle";
case FALLING:
return "Faceplant the floor, headbutt the ground";
case CLIMBING:
return "Climb the highest mountain";
case FLYING:
return "I believe I can fly";
case DIVING:
return "Scuba club 4000";
case PIGGY:
return "OINK! OINK!";
default:
return "Sit and wait?";
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return ImmutableList.of("?");
default:
return ImmutableList.of();
}
}
private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<String>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
break;
case JUMPING:
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
break;
case THROWING:
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
break;
case WRECKING:
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
break;
case CRAFTING:
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
break;
case WALKING:
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
break;
case SWIMMING:
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
break;
case FALLING:
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
break;
case CLIMBING:
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
break;
case FLYING:
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
break;
case DIVING:
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
break;
case PIGGY:
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
break;
}
return messages;
}
private List<String> statsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<String>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77))));
break;
case JUMPING:
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case THROWING:
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87))));
break;
case WRECKING:
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14))));
break;
case CRAFTING:
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case WALKING:
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case SWIMMING:
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FALLING:
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37))));
break;
case CLIMBING:
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FLYING:
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case DIVING:
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case PIGGY:
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
break;
}
return messages;
}
}

View File

@@ -1,88 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.archery.Archery;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String dazeChanceLucky;
private String retrieveChance;
private String retrieveChanceLucky;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
public ArcheryCommand() {
super(PrimarySkillType.ARCHERY);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// ARCHERY_ARROW_RETRIEVAL
if (canRetrieve) {
String[] retrieveStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
// ARCHERY_DAZE
if (canDaze) {
String[] dazeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_DAZE);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
}
// SKILL SHOT
if (canSkillShot) {
skillShotBonus = percent.format(Archery.getDamageBonusPercent(player));
}
}
@Override
protected void permissionsCheck(Player player) {
canSkillShot = canUseSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT);
canDaze = canUseSubskill(player, SubSkillType.ARCHERY_DAZE);
canRetrieve = canUseSubskill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canRetrieve) {
messages.add(getStatMessage(SubSkillType.ARCHERY_ARROW_RETRIEVAL, retrieveChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
}
if (canDaze) {
messages.add(getStatMessage(SubSkillType.ARCHERY_DAZE, dazeChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
}
if (canSkillShot) {
messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ARCHERY);
return textComponents;
}
}

View File

@@ -1,109 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.axes.Axes;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class AxesCommand extends SkillCommand {
private String critChance;
private String critChanceLucky;
private double axeMasteryDamage;
private double impactDamage;
private String skullSplitterLength;
private String skullSplitterLengthEndurance;
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canAxeMastery;
private boolean canImpact;
private boolean canGreaterImpact;
public AxesCommand() {
super(PrimarySkillType.AXES);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// ARMOR IMPACT
if (canImpact) {
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
}
// AXE MASTERY
if (canAxeMastery) {
axeMasteryDamage = Axes.getAxeMasteryBonusDamage(player);
}
// CRITICAL HIT
if (canCritical) {
String[] criticalHitStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.AXES_CRITICAL_STRIKES);
critChance = criticalHitStrings[0];
critChanceLucky = criticalHitStrings[1];
}
// SKULL SPLITTER
if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);
canGreaterImpact = canUseSubskill(player, SubSkillType.AXES_GREATER_IMPACT);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canImpact) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
}
if (canAxeMastery) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", axeMasteryDamage)));
}
if (canCritical) {
messages.add(getStatMessage(SubSkillType.AXES_CRITICAL_STRIKES, critChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
}
if (canGreaterImpact) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
}
if (canSkullSplitter) {
messages.add(getStatMessage(SubSkillType.AXES_SKULL_SPLITTER, skullSplitterLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
return textComponents;
}
}

View File

@@ -1,64 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ExcavationCommand extends SkillCommand {
private String gigaDrillBreakerLength;
private String gigaDrillBreakerLengthEndurance;
private boolean canGigaDrill;
private boolean canTreasureHunt;
public ExcavationCommand() {
super(PrimarySkillType.EXCAVATION);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// GIGA DRILL BREAKER
if (canGigaDrill) {
String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canGigaDrill) {
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
//messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
return textComponents;
}
}

View File

@@ -1,177 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.config.treasure.TreasureConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
import com.gmail.nossr50.core.skills.primary.fishing.FishingManager;
import com.gmail.nossr50.core.skills.treasure.Rarity;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String shakeChance;
private String shakeChanceLucky;
private int fishermansDietRank;
private String biteChance;
private String trapTreasure;
private String commonTreasure;
private String uncommonTreasure;
private String rareTreasure;
private String epicTreasure;
private String legendaryTreasure;
private String recordTreasure;
private String magicChance;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
private boolean canFishermansDiet;
private boolean canMasterAngler;
private boolean canIceFish;
public FishingCommand() {
super(PrimarySkillType.FISHING);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
// TREASURE HUNTER
if (canTreasureHunt) {
lootTier = fishingManager.getLootTier();
// ItemStack drop rates
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
// Magic hunter drop rates
double totalEnchantChance = 0;
for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.RECORD) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
}
if (totalEnchantChance >= 1)
magicChance = percent.format(totalEnchantChance / 100.0);
else
magicChance = percent.format(0);
}
// FISHING_SHAKE
if (canShake) {
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1];
}
// FISHERMAN'S DIET
if (canFishermansDiet) {
fishermansDietRank = calculateRank(skillValue, Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
}
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
}
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
}
double luckyModifier = Permissions.lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D;
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
}
}
@Override
protected void permissionsCheck(Player player) {
canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canFishermansDiet) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_FISHERMANS_DIET, String.valueOf(fishermansDietRank)));
}
if (canIceFish) {
messages.add(getStatMessage(SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_ICE_FISHING.getLocaleStatDescription()));
}
if (canMagicHunt) {
messages.add(getStatMessage(SubSkillType.FISHING_MAGIC_HUNTER, magicChance));
}
if (canMasterAngler) {
//TODO: Update this with more details
messages.add(getStatMessage(false, true, SubSkillType.FISHING_MASTER_ANGLER, biteChance));
}
if (canShake) {
messages.add(getStatMessage(SubSkillType.FISHING_SHAKE, shakeChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
if (canTreasureHunt) {
messages.add(getStatMessage(false, true, SubSkillType.FISHING_TREASURE_HUNTER, String.valueOf(lootTier), String.valueOf(RankUtils.getHighestRank(SubSkillType.FISHING_TREASURE_HUNTER))));
messages.add(getStatMessage(true, true, SubSkillType.FISHING_TREASURE_HUNTER,
String.valueOf(commonTreasure),
String.valueOf(uncommonTreasure),
String.valueOf(rareTreasure),
String.valueOf(epicTreasure),
String.valueOf(legendaryTreasure),
String.valueOf(recordTreasure)));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
return textComponents;
}
}

View File

@@ -1,152 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
private String greenTerraLengthEndurance;
private String greenThumbChance;
private String greenThumbChanceLucky;
private int greenThumbStage;
private int farmersDietRank;
private String doubleDropChance;
private String doubleDropChanceLucky;
private String hylianLuckChance;
private String hylianLuckChanceLucky;
private String shroomThumbChance;
private String shroomThumbChanceLucky;
private boolean hasHylianLuck;
private boolean canGreenTerra;
private boolean canGreenThumbPlants;
private boolean canGreenThumbBlocks;
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean canShroomThumb;
public HerbalismCommand() {
super(PrimarySkillType.HERBALISM);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);
;
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// FARMERS DIET
if (canFarmersDiet) {
farmersDietRank = RankUtils.getRank(player, SubSkillType.HERBALISM_FARMERS_DIET);
}
// GREEN TERRA
if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1];
}
// GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
String[] greenThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_GREEN_THUMB);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
}
// HYLIAN LUCK
if (hasHylianLuck) {
String[] hylianLuckStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_HYLIAN_LUCK);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
}
// SHROOM THUMB
if (canShroomThumb) {
String[] shroomThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_SHROOM_THUMB);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS));
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canFarmersDiet) {
messages.add(getStatMessage(false, true, SubSkillType.HERBALISM_FARMERS_DIET, String.valueOf(farmersDietRank)));
}
if (canGreenTerra) {
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_TERRA, greenTerraLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
//messages.add(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
}
if (canGreenThumbBlocks || canGreenThumbPlants) {
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_THUMB, greenThumbChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
}
if (canGreenThumbPlants) {
messages.add(getStatMessage(true, true, SubSkillType.HERBALISM_GREEN_THUMB, String.valueOf(greenThumbStage)));
}
if (hasHylianLuck) {
messages.add(getStatMessage(SubSkillType.HERBALISM_HYLIAN_LUCK, hylianLuckChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
}
if (canShroomThumb) {
messages.add(getStatMessage(SubSkillType.HERBALISM_SHROOM_THUMB, shroomThumbChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.HERBALISM);
return textComponents;
}
}

View File

@@ -1,121 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String doubleDropChanceLucky;
private String superBreakerLength;
private String superBreakerLengthEndurance;
private int blastMiningRank;
private int bonusTNTDrops;
private double blastRadiusIncrease;
private String oreBonus;
private String debrisReduction;
private String blastDamageDecrease;
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
public MiningCommand() {
super(PrimarySkillType.MINING);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
}
// DOUBLE DROPS
if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.MINING_DOUBLE_DROPS);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
// SUPER BREAKER
if (canSuperBreaker) {
String[] superBreakerStrings = calculateLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBiggerBombs = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
canBlast = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
canDemoExpert = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
canDoubleDrop = Permissions.isSubSkillEnabled(player, SubSkillType.MINING_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canSuperBreaker = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canBiggerBombs) {
messages.add(getStatMessage(true, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastRadiusIncrease)));
//messages.add(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
}
if (canBlast) {
messages.add(getStatMessage(false, true, SubSkillType.MINING_BLAST_MINING, String.valueOf(blastMiningRank), String.valueOf(RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING)), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
//messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
if (canDemoExpert) {
messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease));
//messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
}
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
messages.add(getStatMessage(SubSkillType.MINING_SUPER_BREAKER, superBreakerLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
//messages.add(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.MINING);
return textComponents;
}
}

View File

@@ -1,94 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.listeners.InteractionManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
/**
* This is the command that retrieves data about skills from in-game sources
*/
public class MmoInfoCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
/*
* Only allow players to use this command
*/
if (commandSender instanceof Player) {
if (args.length < 1)
return false;
Player player = (Player) commandSender;
if (Permissions.mmoinfo(player)) {
if (args == null || args[0] == null)
return false;
if (args[0].equalsIgnoreCase("???")) {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
return true;
} else if (InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) {
displayInfo(player, args[0]);
return true;
}
//Not a real skill
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch"));
return true;
}
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], PrimarySkillType.SUBSKILL_NAMES, new ArrayList<String>(PrimarySkillType.SUBSKILL_NAMES.size()));
default:
return ImmutableList.of();
}
}
private void displayInfo(Player player, String subSkillName) {
//Check to see if the skill exists in the new system
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName);
if (abstractSubSkill != null) {
/* New System Skills are programmable */
abstractSubSkill.printInfo(player);
//TextComponentFactory.sendPlayerUrlHeader(player);
} else {
/*
* Skill is only in the old system
*/
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
}
for (SubSkillType subSkillType : SubSkillType.values()) {
if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
subSkillName = subSkillType.getWikiName(subSkillType.toString());
}
//Send Player Wiki Link
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillName);
}
}

View File

@@ -1,131 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.MaterialType;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.repair.ArcaneForging;
import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.primary.repair.RepairManager;
import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class RepairCommand extends SkillCommand {
private String repairMasteryBonus;
private String superRepairChance;
private String superRepairChanceLucky;
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
private boolean canRepairStone;
private boolean canRepairIron;
private boolean canRepairGold;
private boolean canRepairDiamond;
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
private boolean arcaneBypass;
private int diamondLevel;
private int goldLevel;
private int ironLevel;
private int stoneLevel;
public RepairCommand() {
super(PrimarySkillType.REPAIR);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
// REPAIR MASTERY
if (canMasterRepair) {
repairMasteryBonus = percent.format(Math.min(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue), Repair.repairMasteryMaxBonus) / 100D);
}
// SUPER REPAIR
if (canSuperRepair) {
String[] superRepairStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.REPAIR_SUPER_REPAIR);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR);
canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING);
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);
canRepairStone = Permissions.repairMaterialType(player, MaterialType.STONE);
canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING);
canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER);
canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD);
arcaneBypass = Permissions.arcaneBypass(player);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canArcaneForge) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
messages.add(getStatMessage(false, true,
SubSkillType.REPAIR_ARCANE_FORGING,
String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)),
RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING)));
if (ArcaneForging.arcaneForgingEnchantLoss || ArcaneForging.arcaneForgingDowngrades) {
messages.add(getStatMessage(true, true, SubSkillType.REPAIR_ARCANE_FORGING,
String.valueOf(arcaneBypass ? 100 : repairManager.getKeepEnchantChance()),
String.valueOf(arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); //Jesus those parentheses
}
}
if (canMasterRepair) {
messages.add(getStatMessage(false, true, SubSkillType.REPAIR_REPAIR_MASTERY, repairMasteryBonus));
}
if (canSuperRepair) {
messages.add(getStatMessage(SubSkillType.REPAIR_SUPER_REPAIR, superRepairChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
return textComponents;
}
}

View File

@@ -1,72 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SalvageCommand extends SkillCommand {
private boolean canAdvancedSalvage;
private boolean canArcaneSalvage;
public SalvageCommand() {
super(PrimarySkillType.SALVAGE);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// TODO Auto-generated method stub
}
@Override
protected void permissionsCheck(Player player) {
canAdvancedSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ADVANCED_SALVAGE);
canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
if (canAdvancedSalvage) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Ability.Bonus.0"),
LocaleLoader.getString("Salvage.Ability.Bonus.1", salvageManager.getSalvageableAmount())));
}
if (canArcaneSalvage) {
messages.add(getStatMessage(false, true, SubSkillType.SALVAGE_ARCANE_SALVAGE,
String.valueOf(salvageManager.getArcaneSalvageRank()),
String.valueOf(RankUtils.getHighestRank(SubSkillType.SALVAGE_ARCANE_SALVAGE))));
if (Salvage.arcaneSalvageEnchantLoss) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractFull"), percent.format(salvageManager.getExtractFullEnchantChance() / 100)));
}
if (Salvage.arcaneSalvageDowngrades) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Arcane.ExtractPartial"), percent.format(salvageManager.getExtractPartialEnchantChance() / 100)));
}
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SALVAGE);
return textComponents;
}
}

View File

@@ -1,290 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.child.FamilyTree;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.util.skills.PerksUtils;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
private CommandExecutor skillGuideCommand;
public SkillCommand(PrimarySkillType skill) {
this.skill = skill;
skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill);
}
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
boolean isLucky = Permissions.lucky(player, skill);
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
float skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for (int i = 0; i < 2; i++) {
player.sendMessage("");
}
permissionsCheck(player);
dataCalculations(player, skillValue);
sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue);
//Make JSON text components
List<TextComponent> subskillTextComponents = getTextComponents(player);
//Subskills Header
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul")));
//Send JSON text components
TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents);
/*for(TextComponent tc : subskillTextComponents)
{
player.spigot().sendMessage(new TextComponent[]{tc, new TextComponent(": TESTING")});
}*/
//Stats
getStatMessages(player, isLucky, hasEndurance, skillValue);
//Header
//Link Header
if (MainConfig.getInstance().getUrlLinksEnabled()) {
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player);
}
if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
}
return true;
default:
return skillGuideCommand.onCommand(sender, command, label, args);
}
}
private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, float skillValue) {
List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Commands.Stats.Self.Overhaul")));
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
}
private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) {
ChatColor hd1 = ChatColor.DARK_AQUA;
ChatColor c1 = ChatColor.GOLD;
ChatColor c2 = ChatColor.RED;
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if (!skill.isChildSkill()) {
/*
* NON-CHILD SKILLS
*/
//XP GAIN METHOD
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
//LEVEL
player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
} else {
/*
* CHILD SKILLS
*/
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
ArrayList<PrimarySkillType> parentList = new ArrayList<>();
//TODO: Add JSON here
for (PrimarySkillType parent : parents) {
parentList.add(parent);
/*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/
;
}
String parentMessage = "";
for (int i = 0; i < parentList.size(); i++) {
if (i + 1 < parentList.size()) {
parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)));
parentMessage += ChatColor.GRAY + ", ";
} else {
parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)));
}
}
//XP GAIN METHOD
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain.Child")));
player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, parentMessage));
//LEVEL
//player.sendMessage(LocaleLoader.getString("Effects.Child.Overhaul", skillValue, skillValue));
}
/*
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
} else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain.Child")));
player.sendMessage(LocaleLoader.getString("Effects.Child", skillValue));
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Skills.Parents")));
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
for (PrimarySkillType parent : parents) {
player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
}
}
*/
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return ImmutableList.of("?");
default:
return ImmutableList.of();
}
}
protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
}
protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
}
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
int length;
if (abilityLengthCap <= 0) {
length = 2 + (int) (skillValue / abilityLengthVar);
} else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) {
length = Math.min(length, maxLength);
}
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}
protected String getStatMessage(SubSkillType subSkillType, String... vars) {
return getStatMessage(false, false, subSkillType, vars);
}
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
if (isCustom)
//Cast to Object[] to suppress warnings
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, (Object[]) vars));
else {
String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
//Cast to Object[] to suppress warnings
return LocaleLoader.getString(templateKey, (Object[]) mergedList);
}
}
protected abstract void dataCalculations(Player player, float skillValue);
protected abstract void permissionsCheck(Player player);
//protected abstract List<String> effectsDisplay();
protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
protected abstract List<TextComponent> getTextComponents(Player player);
/**
* Checks if a player can use a skill
*
* @param player target player
* @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked
*/
protected boolean canUseSubskill(Player player, SubSkillType subSkillType) {
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
}
}

View File

@@ -1,109 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.Arrays;
public class SkillGuideCommand implements CommandExecutor {
private String header;
private ArrayList<String> guide;
private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(PrimarySkillType skill) {
header = LocaleLoader.getString("Guides.Header", skill.getName());
guide = getGuide(skill);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (!args[0].equals("?")) {
return false;
}
sendGuide(sender, 1);
return true;
case 2:
int totalPages = getTotalPageNumber();
if (!StringUtils.isInt(args[1])) {
sender.sendMessage(invalidPage);
return true;
}
int pageNumber = Integer.parseInt(args[1]);
if (pageNumber > totalPages || pageNumber <= 0) {
sender.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
return true;
}
sendGuide(sender, pageNumber);
return true;
default:
return false;
}
}
private int getTotalPageNumber() {
return (int) Math.ceil(guide.size() / 8.0);
}
private void sendGuide(CommandSender sender, int pageNumber) {
for (String target : grabPageContents(pageNumber)) {
sender.sendMessage(target);
}
}
private ArrayList<String> grabPageContents(int page) {
int pageIndexStart = 8 * (page - 1); // Determine what string to start at
ArrayList<String> allStrings = new ArrayList<String>();
allStrings.add(header);
// Add targeted strings
while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add("");
} else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
}
}
allStrings.add("Page " + page + " of " + getTotalPageNumber());
return allStrings;
}
private ArrayList<String> getGuide(PrimarySkillType skill) {
ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;
}
guide.addAll(Arrays.asList(section));
if (section.length < 8) {
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
guide.add("");
}
}
}
return guide;
}
}

View File

@@ -1,99 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.child.smelting.Smelting;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier;
private String str_secondSmeltChance;
private String str_secondSmeltChanceLucky;
private String str_fluxMiningChance;
private String str_fluxMiningChanceLucky;
private boolean canFuelEfficiency;
private boolean canSecondSmelt;
private boolean canFluxMine;
private boolean canUnderstandTheArt;
public SmeltingCommand() {
super(PrimarySkillType.SMELTING);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// FUEL EFFICIENCY
if (canFuelEfficiency) {
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
}
// FLUX MINING
/*if (canFluxMine) {
String[] fluxMiningStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_FLUX_MINING);
str_fluxMiningChance = fluxMiningStrings[0];
str_fluxMiningChanceLucky = fluxMiningStrings[1];
}*/
// SECOND SMELT
if (canSecondSmelt) {
String[] secondSmeltStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_SECOND_SMELT);
str_secondSmeltChance = secondSmeltStrings[0];
str_secondSmeltChanceLucky = secondSmeltStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
/*if (canFluxMine) {
messages.add(getStatMessage(SubSkillType.SMELTING_FLUX_MINING, str_fluxMiningChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Smelting.Ability.FluxMining", str_fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_fluxMiningChanceLucky) : ""));
}*/
if (canFuelEfficiency) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_FUEL_EFFICIENCY, burnTimeModifier));
}
if (canSecondSmelt) {
messages.add(getStatMessage(SubSkillType.SMELTING_SECOND_SMELT, str_secondSmeltChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", str_secondSmeltChanceLucky) : ""));
}
if (canUnderstandTheArt) {
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SMELTING);
return textComponents;
}
}

View File

@@ -1,108 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class SwordsCommand extends SkillCommand {
private String counterChance;
private String counterChanceLucky;
private int bleedLength;
private String bleedChance;
private String bleedChanceLucky;
private String serratedStrikesLength;
private String serratedStrikesLengthEndurance;
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
public SwordsCommand() {
super(PrimarySkillType.SWORDS);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// SWORDS_COUNTER_ATTACK
if (canCounter) {
String[] counterStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_COUNTER_ATTACK);
counterChance = counterStrings[0];
counterChanceLucky = counterStrings[1];
}
// SWORDS_RUPTURE
if (canBleed) {
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE);
bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1];
}
// SERRATED STRIKES
if (canSerratedStrike) {
String[] serratedStrikesStrings = calculateLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
if (canCounter) {
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterChanceLucky) : ""));
}
if (canBleed) {
messages.add(getStatMessage(SubSkillType.SWORDS_RUPTURE, bleedChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
messages.add(getStatMessage(true, true, SubSkillType.SWORDS_RUPTURE,
String.valueOf(ruptureTicks),
String.valueOf(ruptureDamagePlayers),
String.valueOf(ruptureDamageMobs)));
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note"));
}
if (canSerratedStrike) {
messages.add(getStatMessage(SubSkillType.SWORDS_SERRATED_STRIKES, serratedStrikesLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SWORDS);
return textComponents;
}
}

View File

@@ -1,102 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.taming.Taming;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class TamingCommand extends SkillCommand {
private String goreChance;
private String goreChanceLucky;
private boolean canBeastLore;
private boolean canGore;
private boolean canSharpenedClaws;
private boolean canEnvironmentallyAware;
private boolean canThickFur;
private boolean canShockProof;
private boolean canCallWild;
private boolean canFastFood;
private boolean canHolyHound;
public TamingCommand() {
super(PrimarySkillType.TAMING);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
if (canGore) {
String[] goreStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.TAMING_GORE);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
canFastFood = canUseSubskill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
canGore = canUseSubskill(player, SubSkillType.TAMING_GORE);
canSharpenedClaws = canUseSubskill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
canShockProof = canUseSubskill(player, SubSkillType.TAMING_SHOCK_PROOF);
canThickFur = canUseSubskill(player, SubSkillType.TAMING_THICK_FUR);
canHolyHound = canUseSubskill(player, SubSkillType.TAMING_HOLY_HOUND);
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canEnvironmentallyAware) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
}
if (canFastFood) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
}
if (canGore) {
messages.add(LocaleLoader.getString("Ability.Generic.Template",
LocaleLoader.getString("Taming.Combat.Chance.Gore"),
goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
}
if (canHolyHound) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
}
if (canSharpenedClaws) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
}
if (canShockProof) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
}
if (canThickFur) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, this.skill);
return textComponents;
}
}

View File

@@ -1,129 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
private String ironGripChance;
private String ironGripChanceLucky;
private double ironArmBonus;
private boolean canBerserk;
private boolean canDisarm;
private boolean canIronArm;
private boolean canDeflect;
private boolean canIronGrip;
public UnarmedCommand() {
super(PrimarySkillType.UNARMED);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// UNARMED_ARROW_DEFLECT
if (canDeflect) {
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
;
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
}
// BERSERK
if (canBerserk) {
String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
}
// UNARMED_DISARM
if (canDisarm) {
String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);
;
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
}
// IRON ARM
if (canIronArm) {
ironArmBonus = UserManager.getPlayer(player).getUnarmedManager().getIronArmDamage();
}
// IRON GRIP
if (canIronGrip) {
String[] ironGripStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_IRON_GRIP);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
}
@Override
protected void permissionsCheck(Player player) {
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_IRON_ARM_STYLE);
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
canIronGrip = canUseSubskill(player, SubSkillType.UNARMED_IRON_GRIP);
// TODO: Apparently we forgot about block cracker?
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canDeflect) {
messages.add(getStatMessage(SubSkillType.UNARMED_ARROW_DEFLECT, deflectChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
}
if (canBerserk) {
messages.add(getStatMessage(SubSkillType.UNARMED_BERSERK, berserkLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
//messages.add(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
}
if (canDisarm) {
messages.add(getStatMessage(SubSkillType.UNARMED_DISARM, disarmChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
}
if (canIronArm) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
}
if (canIronGrip) {
messages.add(getStatMessage(SubSkillType.UNARMED_IRON_GRIP, ironGripChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
//messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.UNARMED);
return textComponents;
}
}

View File

@@ -1,96 +0,0 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String treeFellerLengthEndurance;
private String doubleDropChance;
private String doubleDropChanceLucky;
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean canSplinter;
private boolean canBarkSurgeon;
private boolean canNaturesBounty;
public WoodcuttingCommand() {
super(PrimarySkillType.WOODCUTTING);
}
@Override
protected void dataCalculations(Player player, float skillValue) {
// DOUBLE DROPS
if (canDoubleDrop) {
setDoubleDropClassicChanceStrings(player);
}
// TREE FELLER
if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1];
}
}
private void setDoubleDropClassicChanceStrings(Player player) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
;
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
}
@Override
protected void permissionsCheck(Player player) {
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && !skill.getDoubleDropsDisabled() && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canDoubleDrop) {
messages.add(getStatMessage(SubSkillType.WOODCUTTING_HARVEST_LUMBER, doubleDropChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canLeafBlow) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
}
if (canTreeFell) {
messages.add(getStatMessage(SubSkillType.WOODCUTTING_TREE_FELLER, treeFellerLength)
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
}
return messages;
}
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.WOODCUTTING);
return textComponents;
}
}

View File

@@ -1,566 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.skills.ToolType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.skills.primary.excavation.ExcavationManager;
import com.gmail.nossr50.core.skills.primary.herbalism.Herbalism;
import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.primary.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.ItemUtils;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.util.sounds.SoundManager;
import com.gmail.nossr50.core.util.sounds.SoundType;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.core.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.core.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.*;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import java.util.List;
public class BlockListener implements Listener {
private final mcMMO plugin;
public BlockListener(final mcMMO plugin) {
this.plugin = plugin;
}
/**
* Monitor BlockPistonExtend events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock();
movedBlock = movedBlock.getRelative(direction, 2);
for (Block b : event.getBlocks()) {
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
movedBlock = b.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
}
}
}
/**
* Monitor BlockPistonRetract events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
// Get opposite direction so we get correct block
BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock().getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
for (Block block : event.getBlocks()) {
movedBlock = block.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
}
}
/**
* Monitor blocks formed by entities (snowmen)
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState())) {
mcMMO.getPlaceStore().setTrue(event.getBlock());
}
}
/**
* Monitor falling blocks.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue(plugin, event.getBlock().getLocation()));
} else {
List<MetadataValue> values = event.getEntity().getMetadata("mcMMOBlockFall");
if (!values.isEmpty()) {
if (values.get(0).value() == null) return;
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
mcMMO.getPlaceStore().setTrue(event.getBlock());
mcMMO.getPlaceStore().setFalse(spawn);
}
}
}
}
/**
* Monitor BlockPlace events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
BlockState blockState = event.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
// Don't count de-barking wood
if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
mcMMO.getPlaceStore().setTrue(blockState);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) {
mcMMOPlayer.getRepairManager().placedAnvilCheck();
} else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck();
}
}
/**
* Monitor BlockMultiPlace events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
for (BlockState replacedBlockState : event.getReplacedBlockStates()) {
BlockState blockState = replacedBlockState.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockGrow(BlockGrowEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockState blockState = event.getBlock().getState();
if (!BlockUtils.shouldBeWatched(blockState)) {
return;
}
mcMMO.getPlaceStore().setFalse(blockState);
}
/**
* Monitor BlockBreak events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockBreakEvent) {
return;
}
BlockState blockState = event.getBlock().getState();
Location location = blockState.getLocation();
if (!BlockUtils.shouldBeWatched(blockState)) {
return;
}
/* ALCHEMY - Cancel any brew in progress for that BrewingStand */
if (blockState instanceof BrewingStand && Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).cancelBrew();
}
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
/* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) {
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
}
/*
* We don't check the block store here because herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler.
*/
if (PrimarySkillType.HERBALISM.getPermissions(player)) {
herbalismManager.herbalismBlockCheck(blockState);
}
}
/* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && PrimarySkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState);
}
/* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
} else {
woodcuttingManager.woodcuttingBlockCheck(blockState);
}
}
/* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && PrimarySkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState);
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER)) {
excavationManager.gigaDrillBreaker(blockState);
}
}
/* Remove metadata from placed watched blocks */
mcMMO.getPlaceStore().setFalse(blockState);
}
/**
* Handle BlockBreak events where the event is modified.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakHigher(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockBreakEvent) {
return;
}
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
BlockState blockState = event.getBlock().getState();
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (Herbalism.isRecentlyRegrown(blockState)) {
event.setCancelled(true);
return;
}
if (ItemUtils.isSword(heldItem)) {
HerbalismManager herbalismManager = UserManager.getPlayer(player).getHerbalismManager();
if (herbalismManager.canUseHylianLuck()) {
if (herbalismManager.processHylianLuck(blockState)) {
blockState.update(true);
event.setCancelled(true);
} else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR);
blockState.update(true);
event.setCancelled(true);
}
}
}
/*else if (!heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
if (smeltingManager.canUseFluxMining(blockState)) {
if (smeltingManager.processFluxMining(blockState)) {
blockState.update(true);
event.setCancelled(true);
}
}
}*/
}
/**
* Monitor BlockDamage events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
Player player = event.getPlayer();
BlockState blockState = event.getBlock().getState();
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockDamageEvent) {
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
/*
* ABILITY PREPARATION CHECKS
*
* We check permissions here before processing activation.
*/
if (BlockUtils.canActivateAbilities(blockState)) {
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
} else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
}
}
/*
* TREE FELLER SOUNDS
*
* We don't need to check permissions here because they've already been checked for the ability to even activate.
*/
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && MainConfig.getInstance().getTreeFellerSoundsEnabled()) {
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
}
}
private Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
if (metadata.isEmpty()) {
return null;
}
return plugin.getServer().getPlayerExact(metadata.get(0).asString());
}
/**
* Handle BlockDamage events where the event is modified.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
if (event instanceof FakeBlockDamageEvent) {
return;
}
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
Block block = event.getBlock();
BlockState blockState = block.getState();
/*
* ABILITY TRIGGER CHECKS
*
* We don't need to check permissions here because they've already been checked for the ability to even activate.
*/
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
blockState.update(true);
}
} else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
} else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockDamageCleanup(BlockDamageEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
BlockState blockState = event.getBlock().getState();
ItemStack heldItem = player.getInventory().getItemInMainHand();
cleanupAbilityTools(player, mcMMOPlayer, blockState, heldItem);
debugStickDump(player, blockState);
}
public void debugStickDump(Player player, BlockState blockState) {
if (player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) {
if (mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else {
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (WorldGuardManager.getInstance().hasMainFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region");
else
player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region");
if (WorldGuardManager.getInstance().hasXPFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is permitted for this player in this region");
else
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");
}
if (blockState instanceof Furnace) {
Furnace furnace = (Furnace) blockState;
if (furnace.hasMetadata(mcMMO.furnaceMetadataKey)) {
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock());
if (furnacePlayer != null) {
player.sendMessage("[mcMMO DEBUG] This furnace is owned by player " + furnacePlayer.getName());
}
} else
player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner");
}
if (ExperienceConfig.getInstance().isExperienceBarsEnabled())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
}
}
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
if (ChunkConversionOptions.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem);
}
} else {
if ((mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) && !BlockUtils.affectedBySuperBreaker(blockState)) || (mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER) && !BlockUtils.affectedByGigaDrillBreaker(blockState))) {
SkillUtils.handleAbilitySpeedDecrease(player);
}
}
}
}

View File

@@ -1,860 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.meta.OldName;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.archery.Archery;
import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
import com.gmail.nossr50.core.skills.primary.mining.BlastMining;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.taming.Taming;
import com.gmail.nossr50.core.skills.primary.taming.TamingManager;
import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.CombatUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.core.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.core.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.core.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import java.util.List;
public class EntityListener implements Listener {
private final mcMMO plugin;
public EntityListener(final mcMMO plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTargetEntity(EntityTargetLivingEntityEvent event) {
if (!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
return;
//Prevent entities from giving XP if they target endermite
if (event.getTarget() instanceof Endermite) {
if (event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
Entity projectile = event.getProjectile();
if (!(projectile instanceof Arrow)) {
return;
}
ItemStack bow = event.getBow();
if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
Projectile projectile = event.getEntity();
if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) {
return;
}
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0));
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation()));
}
/**
* Monitor EntityChangeBlock events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Block block = event.getBlock();
// When the event is fired for the falling block that changes back to a
// normal block
// event.getBlock().getType() returns AIR
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
return;
}
Entity entity = event.getEntity();
if (entity instanceof FallingBlock || entity instanceof Enderman) {
boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
} else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
}
} else if ((block.getType() == Material.REDSTONE_ORE)) {
return;
} else {
if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block);
}
}
}
/**
* Handle EntityDamageByEntity events that involve modifying the event.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event instanceof FakeEntityDamageByEntityEvent) {
return;
}
if (event.getEntity() instanceof ArmorStand) {
return;
}
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey)) {
event.setCancelled(true);
return;
}
double damage = event.getFinalDamage();
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
if (attacker instanceof Player) {
Player player = (Player) attacker;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
if (damage <= 0) {
if (defender instanceof Player && attacker instanceof Player) {
Player defendingPlayer = (Player) defender;
Player attackingPlayer = (Player) attacker;
if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
//If friendly fire is off don't allow players to hurt one another
if (!MainConfig.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return;
}
}
}
return;
}
/*
As far as I can tell at one point we registered meta-data about custom damage and we no longer do that.
if (defender.hasMetadata(mcMMO.customDamageKey)) {
defender.removeMetadata(mcMMO.customDamageKey, plugin);
return;
}
*/
if (Misc.isNPCEntity(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return;
}
LivingEntity target = (LivingEntity) defender;
if (CombatUtils.isInvincible(target, damage)) {
return;
}
if (Misc.isNPCEntity(attacker)) {
return;
}
if (attacker instanceof Projectile) {
ProjectileSource projectileSource = ((Projectile) attacker).getShooter();
if (projectileSource instanceof LivingEntity) {
attacker = (LivingEntity) projectileSource;
}
} else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
attacker = (Entity) animalTamer;
}
} else if (attacker instanceof TNTPrimed && defender instanceof Player) {
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
return;
}
}
if (defender instanceof Player && attacker instanceof Player) {
Player defendingPlayer = (Player) defender;
Player attackingPlayer = (Player) attacker;
if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) {
return;
}
// We want to make sure we're not gaining XP or applying abilities
// when we hit ourselves
if (defendingPlayer.equals(attackingPlayer)) {
return;
}
//Party Friendly Fire
if (!MainConfig.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return;
}
}
CombatUtils.processCombatAttack(event, attacker, target);
CombatUtils.handleHealthbars(attacker, target, event.getFinalDamage(), plugin);
/**
* This sets entity names back to whatever they are supposed to be
*/
if (!(attacker instanceof Player) && defender instanceof Player) {
if (event.getFinalDamage() >= ((LivingEntity) defender).getHealth()) {
List<MetadataValue> metadataValue = attacker.getMetadata("mcMMO_oldName");
if (metadataValue.size() <= 0)
return;
if (metadataValue != null) {
OldName oldName = (OldName) metadataValue.get(0);
attacker.setCustomName(oldName.asString());
attacker.setCustomNameVisible(false);
}
}
}
}
/**
* Handle EntityDamage events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
/*
* Process Registered Interactions
*/
InteractionManager.processEvent(event, plugin, InteractType.ON_ENTITY_DAMAGE);
/*
* Old code
*/
if (event instanceof FakeEntityDamageEvent) {
return;
}
double damage = event.getFinalDamage();
if (damage <= 0) {
return;
}
Entity entity = event.getEntity();
/*
As far as I can tell at one point we registered meta-data about custom damage and we no longer do that.
if (entity.hasMetadata(mcMMO.customDamageKey)) {
entity.removeMetadata(mcMMO.customDamageKey, plugin);
return;
}
*/
if (Misc.isNPCEntity(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
return;
}
LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, damage)) {
return;
}
DamageCause cause = event.getCause();
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
/* Check for invincibility */
if (mcMMOPlayer.getGodMode()) {
event.setCancelled(true);
return;
}
if (event.getFinalDamage() >= 1) {
mcMMOPlayer.actualizeRecentlyHurt();
}
} else if (livingEntity instanceof Tameable) {
Tameable pet = (Tameable) livingEntity;
AnimalTamer owner = pet.getOwner();
if (owner instanceof Player) {
Player player = (Player) owner;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
}
if (Taming.canPreventDamage(pet, owner)) {
Player player = (Player) owner;
Wolf wolf = (Wolf) pet;
TamingManager tamingManager = UserManager.getPlayer(player).getTamingManager();
switch (cause) {
case CONTACT:
case FIRE:
case LAVA:
if (tamingManager.canUseEnvironmentallyAware()) {
tamingManager.processEnvironmentallyAware(wolf, event.getDamage());
}
return;
case FALL:
if (tamingManager.canUseEnvironmentallyAware()) {
event.setCancelled(true);
}
return;
case ENTITY_ATTACK:
case PROJECTILE:
if (tamingManager.canUseThickFur()) {
event.setDamage(Taming.processThickFur(wolf, event.getDamage()));
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
}
}
return;
case FIRE_TICK:
if (tamingManager.canUseThickFur()) {
Taming.processThickFurFire(wolf);
}
return;
case MAGIC:
case POISON:
case WITHER:
if (tamingManager.canUseHolyHound()) {
Taming.processHolyHound(wolf, event.getDamage());
}
return;
case BLOCK_EXPLOSION:
case ENTITY_EXPLOSION:
case LIGHTNING:
if (tamingManager.canUseShockProof()) {
event.setDamage(Taming.processShockProof(wolf, event.getDamage()));
if (event.getFinalDamage() == 0) {
event.setCancelled(true);
}
}
return;
default:
return;
}
}
}
}
/**
* Monitor EntityDeath events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity();
if (Misc.isNPCEntity(entity)) {
return;
}
if (entity.hasMetadata(mcMMO.customNameKey)) {
entity.setCustomName(entity.getMetadata(mcMMO.customNameKey).get(0).asString());
entity.removeMetadata(mcMMO.customNameKey, plugin);
}
if (entity.hasMetadata(mcMMO.customVisibleKey)) {
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
entity.removeMetadata(mcMMO.customVisibleKey, plugin);
}
if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
entity.removeMetadata(mcMMO.entityMetadataKey, plugin);
}
}
/**
* Monitor EntityDeath events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity();
if (Misc.isNPCEntity(entity)) {
return;
}
Archery.arrowRetrievalCheck(entity);
}
/**
* Monitor CreatureSpawn events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
LivingEntity entity = event.getEntity();
switch (event.getSpawnReason()) {
case NETHER_PORTAL:
case SPAWNER:
case SPAWNER_EGG:
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
Entity passenger = entity.getPassenger();
if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
return;
case BREEDING:
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue);
return;
default:
return;
}
}
/**
* Handle ExplosionPrime events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
// We can make this assumption because we (should) be the only ones
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
}
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
// We can make this assumption because we (should) be the only ones
// using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0);
}
}
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
return;
}
event.blockList().clear();
}
/**
* Handle FoodLevelChange events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
if (!(entity instanceof Player)) {
return;
}
Player player = (Player) entity;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
int foodChange = newFoodLevel - currentFoodLevel;
if (foodChange <= 0) {
return;
}
/*
* Some foods have 3 ranks Some foods have 5 ranks The number of ranks
* is based on how 'common' the item is We can adjust this quite easily
* if we find something is giving too much of a bonus
*/
switch (player.getInventory().getItemInMainHand().getType()) {
case BAKED_POTATO: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000
*/
case BEETROOT:
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
case CARROT: /*
* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
* 1000
*/
case GOLDEN_CARROT: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000
*/
case MUSHROOM_STEW: /*
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
* 1000
*/
case PUMPKIN_PIE: /*
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
* 1000
*/
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON_SLICE: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /*
* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
* @ 1000
*/
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
}
return;
case COOKED_SALMON: /*
* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
* 1000
*/
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
}
return;
case SALMON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
}
return;
default:
return;
}
}
/**
* Monitor EntityTame events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event instanceof FakeEntityTameEvent) {
return;
}
Player player = (Player) event.getOwner();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
LivingEntity entity = event.getEntity();
if (!UserManager.hasPlayerDataKey(player) || Misc.isNPCEntity(entity) || entity.hasMetadata(mcMMO.entityMetadataKey)) {
return;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
}
/**
* Handle EntityTarget events.
*
* @param event The event to process
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
Entity entity = event.getEntity();
Entity target = event.getTarget();
if (!(entity instanceof Tameable) || !(target instanceof Player)) {
return;
}
Player player = (Player) target;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
Tameable tameable = (Tameable) entity;
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
return;
}
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player,
// and the owner is in the same party
// So we can make some assumptions here, about our casting and our check
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
event.setCancelled(true);
}
}
/**
* Handle PotionSplash events in order to fix broken Splash Potion of
* Saturation.
*
* @param event The event to process
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
if (!effect.getType().equals(PotionEffectType.SATURATION)) {
return;
}
for (LivingEntity entity : event.getAffectedEntities()) {
int duration = (int) (effect.getDuration() * event.getIntensity(entity));
entity.addPotionEffect(new PotionEffect(effect.getType(), duration, effect.getAmplifier(), effect.isAmbient()));
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPigZapEvent(PigZapEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {
event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
}
}

View File

@@ -1,107 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.core.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.mcMMO;
import org.bukkit.event.Event;
import java.util.ArrayList;
import java.util.HashMap;
public class InteractionManager {
private static HashMap<InteractType, ArrayList<Interaction>> interactRegister;
private static HashMap<String, AbstractSubSkill> subSkillNameMap; //Used for mmoinfo optimization
private static ArrayList<AbstractSubSkill> subSkillList;
/**
* Registers subskills with the Interaction registration
*
* @param abstractSubSkill the target subskill to register
*/
public static void registerSubSkill(AbstractSubSkill abstractSubSkill) {
/* INIT MAPS */
if (interactRegister == null)
interactRegister = new HashMap<>();
if (subSkillList == null)
subSkillList = new ArrayList<>();
if (subSkillNameMap == null)
subSkillNameMap = new HashMap<>();
//Store a unique copy of each subskill
if (!subSkillList.contains(abstractSubSkill))
subSkillList.add(abstractSubSkill);
//Init ArrayList
if (interactRegister.get(abstractSubSkill.getInteractType()) == null)
interactRegister.put(abstractSubSkill.getInteractType(), new ArrayList<>());
//Registration array reference
ArrayList<Interaction> arrayRef = interactRegister.get(abstractSubSkill.getInteractType());
//Register skill
arrayRef.add(abstractSubSkill);
String lowerCaseName = abstractSubSkill.getConfigKeyName().toLowerCase();
//Register in name map
if (subSkillNameMap.get(lowerCaseName) == null)
subSkillNameMap.put(lowerCaseName, abstractSubSkill);
System.out.println("[mcMMO] registered subskill: " + abstractSubSkill.getConfigKeyName());
}
/**
* Grabs the registered abstract skill by its name
* Is not case sensitive
*
* @param name name of subskill, not case sensitive
* @return null if the subskill is not registered
*/
public static AbstractSubSkill getAbstractByName(String name) {
return subSkillNameMap.get(name.toLowerCase());
}
/**
* Processes the associated Interactions for this event
*
* @param event target event
* @param plugin instance of mcMMO plugin
* @param curInteractType the associated interaction type
*/
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) {
for (Interaction interaction : interactRegister.get(curInteractType)) {
interaction.doInteraction(event, plugin);
}
}
/**
* Returns the list that contains all unique instances of registered Interaction classes
* Interactions are extensions of abstract classes that represent modifying behaviours in Minecraft through events
*
* @return the unique collection of all registered Interaction classes
*/
public static ArrayList<AbstractSubSkill> getSubSkillList() {
return subSkillList;
}
public static boolean hasSubSkill(String name) {
return getAbstractByName(name) != null;
}
public static boolean hasSubSkill(SubSkillType subSkillType) {
return hasSubSkill(subSkillType.getNiceNameNoSpaces(subSkillType));
}
/**
* Returns the associative map which contains all registered interactions
*
* @return the interact register
*/
public static HashMap<InteractType, ArrayList<Interaction>> getInteractRegister() {
return interactRegister;
}
}

View File

@@ -1,456 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyPotionBrewer;
import com.gmail.nossr50.core.util.ItemUtils;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.core.events.fake.FakeBrewEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.BrewingStand;
import org.bukkit.block.Furnace;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.*;
import org.bukkit.metadata.MetadataValue;
import java.util.List;
public class InventoryListener implements Listener {
private final mcMMO plugin;
public InventoryListener(final mcMMO plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null) {
return;
}
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0)
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
return;
}
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState();
ItemStack smelting = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getSmelting() : null;
if (!ItemUtils.isSmeltable(smelting)) {
return;
}
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.isSubSkillEnabled(player, SubSkillType.SMELTING_FUEL_EFFICIENCY)) {
return;
}
event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Block furnaceBlock = event.getBlock();
ItemStack smelting = event.getSource();
if (!ItemUtils.isSmeltable(smelting)) {
return;
}
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.SMELTING.getPermissions(player)) {
return;
}
event.setResult(UserManager.getPlayer(player).getSmeltingManager().smeltProcessing(smelting, event.getResult()));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = event.getBlock();
if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) {
return;
}
Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !Permissions.vanillaXpBoost(player, PrimarySkillType.SMELTING)) {
return;
}
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop());
event.setExpToDrop(exp);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryClickEventNormal(InventoryClickEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
Inventory inventory = event.getInventory();
if (event.getWhoClicked() instanceof Player) {
Player player = ((Player) event.getWhoClicked()).getPlayer();
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock != null) {
if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0)
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p);
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer(player).getPlayerMetadata());
}
}
if (!(inventory instanceof BrewerInventory)) {
return;
}
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return;
}
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
BrewingStand stand = (BrewingStand) holder;
ItemStack clicked = event.getCurrentItem();
ItemStack cursor = event.getCursor();
if ((clicked != null && (clicked.getType() == Material.POTION || clicked.getType() == Material.SPLASH_POTION || clicked.getType() == Material.LINGERING_POTION)) || (cursor != null && (cursor.getType() == Material.POTION || cursor.getType() == Material.SPLASH_POTION || cursor.getType() == Material.LINGERING_POTION))) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
}
ClickType click = event.getClick();
InventoryType.SlotType slot = event.getSlotType();
if (click.isShiftClick()) {
switch (slot) {
case FUEL:
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
case CONTAINER:
case QUICKBAR:
if (!AlchemyPotionBrewer.isValidIngredient(player, clicked)) {
return;
}
if (!AlchemyPotionBrewer.transferItems(event.getView(), event.getRawSlot(), click)) {
return;
}
event.setCancelled(true);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
default:
return;
}
} else if (slot == InventoryType.SlotType.FUEL) {
boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked);
if (AlchemyPotionBrewer.isEmpty(cursor)) {
if (emptyClicked && click == ClickType.NUMBER_KEY) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
}
AlchemyPotionBrewer.scheduleCheck(player, stand);
} else if (emptyClicked) {
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
int amount = cursor.getAmount();
if (click == ClickType.LEFT || (click == ClickType.RIGHT && amount == 1)) {
event.setCancelled(true);
event.setCurrentItem(cursor.clone());
event.setCursor(null);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
} else if (click == ClickType.RIGHT) {
event.setCancelled(true);
ItemStack one = cursor.clone();
one.setAmount(1);
ItemStack rest = cursor.clone();
rest.setAmount(amount - 1);
event.setCurrentItem(one);
event.setCursor(rest);
AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand);
}
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
Inventory inventory = event.getInventory();
if (!(inventory instanceof BrewerInventory)) {
return;
}
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
HumanEntity whoClicked = event.getWhoClicked();
if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.isSubSkillEnabled(whoClicked, SubSkillType.ALCHEMY_CONCOCTIONS)) {
return;
}
if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
return;
}
ItemStack cursor = event.getCursor();
ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();
if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
// Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
return;
}
event.setCancelled(true);
AlchemyPotionBrewer.scheduleUpdate(inventory);
}
}
// Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBrew(BrewEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (event instanceof FakeBrewEvent)
return;
Location location = event.getBlock().getLocation();
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).finishImmediately();
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
return;
Inventory inventory = event.getDestination();
if (!(inventory instanceof BrewerInventory)) {
return;
}
InventoryHolder holder = inventory.getHolder();
if (!(holder instanceof BrewingStand)) {
return;
}
ItemStack item = event.getItem();
if (MainConfig.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
event.setCancelled(true);
return;
}
if (MainConfig.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
event.setCancelled(true);
return;
}
if (MainConfig.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClickEvent(InventoryClickEvent event) {
SkillUtils.removeAbilityBuff(event.getCurrentItem());
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
SkillUtils.removeAbilityBuff(event.getPlayer().getInventory().getItemInMainHand());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return;
final HumanEntity whoClicked = event.getWhoClicked();
if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) {
return;
}
ItemStack result = event.getRecipe().getResult();
if (!ItemUtils.isMcMMOItem(result)) {
return;
}
Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0);
}
private Block processInventoryOpenOrCloseEvent(Inventory inventory) {
if (!(inventory instanceof FurnaceInventory)) {
return null;
}
Furnace furnace = (Furnace) inventory.getHolder();
if (furnace == null) {
return null;
}
return furnace.getBlock();
}
private Player getPlayerFromFurnace(Block furnaceBlock) {
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
if (metadata.isEmpty()) {
return null;
}
return plugin.getServer().getPlayerExact(metadata.get(0).asString());
}
}

View File

@@ -1,804 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.chat.ChatManager;
import com.gmail.nossr50.core.chat.ChatManagerFactory;
import com.gmail.nossr50.core.chat.PartyChatManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.ShareHandler;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.skills.primary.fishing.FishingManager;
import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.primary.repair.RepairManager;
import com.gmail.nossr50.core.skills.primary.taming.TamingManager;
import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.util.sounds.SoundManager;
import com.gmail.nossr50.core.util.sounds.SoundType;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.*;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class PlayerListener implements Listener {
private final mcMMO plugin;
public PlayerListener(final mcMMO plugin) {
this.plugin = plugin;
}
/**
* Monitor PlayerTeleportEvents.
* <p>
* These events are monitored for the purpose of setting the
* player's last teleportation timestamp, in order to prevent
* possible Acrobatics exploitation.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || MainConfig.getInstance().getXPAfterTeleportCooldown() <= 0 || event.getFrom().equals(event.getTo())) {
return;
}
UserManager.getPlayer(player).actualizeTeleportATS();
}
/**
* Handle PlayerDeathEvents at the lowest priority.
* <p>
* These events are used to modify the death message of a player when
* needed to correct issues potentially caused by the custom naming used
* for mob healthbars.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDeathLowest(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
String deathMessage = event.getDeathMessage();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getEntity()))
return;
}
if (deathMessage == null) {
return;
}
Player player = event.getEntity();
event.setDeathMessage(MobHealthbarUtils.fixDeathMessage(deathMessage, player));
}
/**
* Monitor PlayerDeathEvents.
* <p>
* These events are monitored for the purpose of dealing the penalties
* associated with hardcore and vampirism modes. If neither of these
* modes are enabled, or if the player who died has hardcore bypass
* permissions, this handler does nothing.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeathMonitor(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
boolean statLossEnabled = HardcoreManager.isStatLossEnabled();
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
if (!statLossEnabled && !vampirismEnabled) {
return;
}
Player killedPlayer = event.getEntity();
if (!killedPlayer.hasMetadata(mcMMO.playerDataKey) || Permissions.hardcoreBypass(killedPlayer)) {
return;
}
Player killer = killedPlayer.getKiller();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(killedPlayer))
return;
}
if (statLossEnabled || (killer != null && vampirismEnabled)) {
if (EventUtils.callPreDeathPenaltyEvent(killedPlayer).isCancelled()) {
return;
}
if (killer != null && vampirismEnabled) {
HardcoreManager.invokeVampirism(killer, killedPlayer);
}
if (statLossEnabled) {
HardcoreManager.invokeStatPenalty(killedPlayer);
}
}
}
/**
* Monitor PlayerChangedWorldEvents.
* <p>
* These events are monitored for the purpose of removing god mode or
* player parties if they are not allowed on the world the player has
* changed to.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer.checkGodMode();
mcMMOPlayer.checkParty();
}
/**
* Monitor PlayerDropItemEvents.
* <p>
* These events are monitored for the purpose of flagging sharable
* dropped items, as well as removing ability buffs from pickaxes
* and shovels.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack();
if (ItemUtils.isSharable(dropStack)) {
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
}
SkillUtils.removeAbilityBuff(dropStack);
}
/**
* Handle PlayerFishEvents at the highest priority.
* <p>
* These events are used for the purpose of handling our anti-exploit
* code, as well as dealing with ice fishing.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
switch (event.getState()) {
case CAUGHT_FISH:
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
Item fishingCatch = (Item) event.getCaught();
if (MainConfig.getInstance().getFishingOverrideTreasures() &&
fishingCatch.getItemStack().getType() != Material.SALMON &&
fishingCatch.getItemStack().getType() != Material.COD &&
fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH &&
fishingCatch.getItemStack().getType() != Material.PUFFERFISH) {
fishingCatch.setItemStack(new ItemStack(Material.SALMON, 1));
}
if (Permissions.vanillaXpBoost(player, PrimarySkillType.FISHING)) {
//Don't modify XP below vanilla values
if (fishingManager.handleVanillaXpBoost(event.getExpToDrop()) > 1)
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
}
return;
case IN_GROUND:
Block block = player.getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
cancelFishingEventAndDropXp(event, player);
fishingManager.iceFishing(event.getHook(), block);
}
return;
default:
return;
}
}
private void cancelFishingEventAndDropXp(PlayerFishEvent event, Player player) {
event.setCancelled(true);
ExperienceOrb experienceOrb = (ExperienceOrb) player.getWorld().spawnEntity(player.getEyeLocation(), EntityType.EXPERIENCE_ORB);
experienceOrb.setExperience(event.getExpToDrop());
}
/**
* Monitor PlayerFishEvents.
* <p>
* These events are monitored for the purpose of handling the various
* Fishing skills and abilities.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player) || !PrimarySkillType.FISHING.getPermissions(player)) {
return;
}
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
Entity caught = event.getCaught();
//event.setExpToDrop(event.getExpToDrop()); //Redundant?
switch (event.getState()) {
case FISHING:
if (fishingManager.canMasterAngler()) {
fishingManager.masterAngler(event.getHook());
fishingManager.setFishingTarget();
}
return;
case CAUGHT_FISH:
if (fishingManager.exploitPrevention(event.getHook().getBoundingBox()))
return;
fishingManager.handleFishing((Item) caught);
fishingManager.setFishingTarget();
return;
case CAUGHT_ENTITY:
if (fishingManager.canShake(caught)) {
fishingManager.shakeCheck((LivingEntity) caught);
fishingManager.setFishingTarget();
}
return;
default:
return;
}
}
/**
* Handle PlayerPickupItemEvents at the highest priority.
* <p>
* These events are used to handle item sharing between party members and
* are also used to handle item pickup for the Unarmed skill.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(EntityPickupItemEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack();
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
event.setCancelled(true);
}
return;
}
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (event.isCancelled()) {
SoundManager.sendSound(player, player.getLocation(), SoundType.POP);
return;
}
}
/*if (player.getInventory().getItemInMainHand().getType() == Material.AIR) {
Unarmed.handleItemPickup(player, event);
*//*boolean cancel = MainConfig.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
event.setCancelled(cancel);
if (pickupSuccess) {
return;
}*//*
}*/
}
}
/**
* Monitor PlayerQuitEvents.
* <p>
* These events are monitored for the purpose of resetting player
* variables and other garbage collection tasks that must take place when
* a player exits the server.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
mcMMOPlayer.logout(false);
}
/**
* Monitor PlayerJoinEvents.
* <p>
* These events are monitored for the purpose of initializing player
* variables, as well as handling the MOTD display and other important
* join messages.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
return;
}
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
if (MainConfig.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
}
if (plugin.isXPEventEnabled()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
}
/**
* Monitor PlayerRespawnEvents.
* <p>
* These events are monitored for the purpose of setting the
* player's last respawn timestamp, in order to prevent
* possible exploitation.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
UserManager.getPlayer(player).actualizeRespawnATS();
}
/**
* Handle PlayerInteractEvents at the lowest priority.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractLowest(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
MiningManager miningManager = mcMMOPlayer.getMiningManager();
Block block = event.getClickedBlock();
ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
Material type = block.getType();
if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to repair an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(true)) {
repairManager.handleRepair(heldItem);
player.updateInventory();
}
}
/* SALVAGE CHECKS */
else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || salvageManager.checkConfirmation(true)) {
SkillUtils.handleAbilitySpeedDecrease(player);
salvageManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory();
}
}
}
/* BLAST MINING CHECK */
else if (miningManager.canDetonate()) {
if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
} else {
miningManager.remoteDetonation();
}
}
break;
case LEFT_CLICK_BLOCK:
type = block.getType();
if (!MainConfig.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel repairing an enchanted item
if (repairManager.checkConfirmation(false)) {
repairManager.setLastAnvilUse(0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
}
}
/* SALVAGE CHECKS */
else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
SalvageManager salvageManager = mcMMOPlayer.getSalvageManager();
// Cancel salvaging an enchanted item
if (salvageManager.checkConfirmation(false)) {
salvageManager.setLastAnvilUse(0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
}
}
}
break;
default:
break;
}
}
/**
* Monitor PlayerInteractEvents.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return;
}
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
if (player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break;
}
Block block = event.getClickedBlock();
BlockState blockState = block.getState();
/* ACTIVATION & ITEM CHECKS */
if (BlockUtils.canActivateTools(blockState)) {
if (MainConfig.getInstance().getAbilitiesEnabled()) {
if (BlockUtils.canActivateHerbalism(blockState)) {
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
}
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.MINING);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.WOODCUTTING);
}
ChimaeraWing.activationCheck(player);
}
/* GREEN THUMB CHECK */
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
if (heldItem.getType() == Material.BONE_MEAL) {
switch (blockState.getType()) {
case BEETROOTS:
case CARROT:
case COCOA:
case WHEAT:
case NETHER_WART_BLOCK:
case POTATO:
mcMMO.getPlaceStore().setFalse(blockState);
}
}
if (herbalismManager.canGreenThumbBlock(blockState)) {
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
break;
case RIGHT_CLICK_AIR:
if (player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break;
}
/* ACTIVATION CHECKS */
if (MainConfig.getInstance().getAbilitiesEnabled()) {
mcMMOPlayer.processAbilityActivation(PrimarySkillType.AXES);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.HERBALISM);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.MINING);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(PrimarySkillType.WOODCUTTING);
}
/* ITEM CHECKS */
ChimaeraWing.activationCheck(player);
/* BLAST MINING CHECK */
MiningManager miningManager = mcMMOPlayer.getMiningManager();
if (miningManager.canDetonate()) {
miningManager.remoteDetonation();
}
break;
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
if (!player.isSneaking()) {
break;
}
/* CALL OF THE WILD CHECKS */
Material type = heldItem.getType();
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) {
tamingManager.summonWolf();
} else if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) {
tamingManager.summonOcelot();
} else if (type == MainConfig.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) {
tamingManager.summonHorse();
}
break;
default:
break;
}
}
/**
* Handle PlayerChatEvents at high priority.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(player);
if (mcMMOPlayer == null) {
mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
mcMMO.p.debug("Party & Admin chat will not work properly for this player.");
return;
}
ChatManager chatManager = null;
if (mcMMOPlayer.isChatEnabled(ChatMode.PARTY)) {
Party party = mcMMOPlayer.getParty();
if (party == null) {
mcMMOPlayer.disableChat(ChatMode.PARTY);
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(party);
} else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN);
}
if (chatManager != null) {
chatManager.handleChat(player, event.getMessage(), event.isAsynchronous());
event.setCancelled(true);
}
}
/**
* Handle "ugly" aliasing /skillname commands, since setAliases doesn't work.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (!MainConfig.getInstance().getLocale().equalsIgnoreCase("en_US")) {
String message = event.getMessage();
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase();
// Do these ACTUALLY have to be lower case to work properly?
for (PrimarySkillType skill : PrimarySkillType.values()) {
String skillName = skill.toString().toLowerCase();
String localizedName = skill.getName().toLowerCase();
if (lowerCaseCommand.equals(localizedName)) {
event.setMessage(message.replace(command, skillName));
break;
}
if (lowerCaseCommand.equals(skillName)) {
break;
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
/* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
}
mcMMO.getHolidayManager().handleStatisticEvent(event);
}
}

View File

@@ -1,133 +0,0 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.core.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.core.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.core.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
public class SelfListener implements Listener {
//Used in task scheduling and other things
private final mcMMO plugin;
public SelfListener(mcMMO plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
Player player = event.getPlayer();
PrimarySkillType skill = event.getSkill();
//Players can gain multiple levels especially during xprate events
for (int i = 0; i < event.getLevelsGained(); i++) {
int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
}
if (MainConfig.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill);
if (!MainConfig.getInstance().getLevelUpEffectsEnabled()) {
return;
}
if ((event.getSkillLevel() % MainConfig.getInstance().getLevelUpEffectsTier()) == 0) {
skill.celebrateLevelUp(player);
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
if (MainConfig.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
if (MainConfig.getInstance().getScoreboardsEnabled())
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
Player player = event.getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PrimarySkillType primarySkillType = event.getSkill();
//WorldGuard XP Check
if (event.getXpGainReason() == XPGainReason.PVE ||
event.getXpGainReason() == XPGainReason.PVP ||
event.getXpGainReason() == XPGainReason.SHARED_PVE ||
event.getXpGainReason() == XPGainReason.SHARED_PVP) {
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasXPFlag(player)) {
event.setRawXpGained(0);
event.setCancelled(true);
}
}
}
if (event.getXpGainReason() == XPGainReason.COMMAND) {
return;
}
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(primarySkillType);
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
// Diminished returns is turned off
return;
}
final float rawXp = event.getRawXpGained();
if (rawXp < 0) {
// Don't calculate for XP subtraction
return;
}
if (primarySkillType.isChildSkill()) {
return;
}
float guaranteedMinimum = ExperienceConfig.getInstance().getDiminishedReturnsCap() * rawXp;
float modifiedThreshold = (float) (threshold / primarySkillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
float difference = (mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) - modifiedThreshold) / modifiedThreshold;
if (difference > 0) {
// System.out.println("Total XP Earned: " + mcMMOPlayer.getProfile().getRegisteredXpGain(primarySkillType) + " / Threshold value: " + threshold);
// System.out.println(difference * 100 + "% over the threshold!");
// System.out.println("Previous: " + event.getRawXpGained());
// System.out.println("Adjusted XP " + (event.getRawXpGained() - (event.getRawXpGained() * difference)));
float newValue = rawXp - (rawXp * difference);
/*
* Make sure players get a guaranteed minimum of XP
*/
//If there is no guaranteed minimum proceed, otherwise only proceed if newValue would be higher than our guaranteed minimum
if (guaranteedMinimum <= 0 || newValue > guaranteedMinimum) {
if (newValue > 0) {
event.setRawXpGained(newValue);
} else {
event.setCancelled(true);
}
} else {
event.setRawXpGained(guaranteedMinimum);
}
}
}
}

View File

@@ -1,564 +0,0 @@
package com.gmail.nossr50;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.mods.ArmorConfigManager;
import com.gmail.nossr50.config.mods.BlockConfigManager;
import com.gmail.nossr50.config.mods.EntityConfigManager;
import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
import com.gmail.nossr50.core.config.*;
import com.gmail.nossr50.core.config.treasure.TreasureConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.runnables.CheckDateTask;
import com.gmail.nossr50.core.runnables.SaveTimerTask;
import com.gmail.nossr50.core.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.core.runnables.database.UserPurgeTask;
import com.gmail.nossr50.core.runnables.party.PartyAutoKickTask;
import com.gmail.nossr50.core.runnables.player.ClearRegisteredXPGainTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.runnables.player.PowerLevelUpdatingTask;
import com.gmail.nossr50.core.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.config.ChildConfig;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.SimpleSalvageableManager;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
import com.gmail.nossr50.core.skills.primary.repair.repairables.RepairableManager;
import com.gmail.nossr50.core.skills.primary.repair.repairables.SimpleRepairableManager;
import com.gmail.nossr50.core.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.core.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.core.util.experience.FormulaManager;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.upgrade.UpgradeManager;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.util.*;
import com.google.common.base.Charsets;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class mcMMO extends JavaPlugin {
/* Metadata Values */
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
public final static String funfettiMetadataKey = "mcMMO: Funfetti";
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
public final static String customNameKey = "mcMMO: Custom Name";
public final static String customVisibleKey = "mcMMO: Name Visibility";
public final static String droppedItemKey = "mcMMO: Tracked Item";
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
public final static String bowForceKey = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
//public final static String customDamageKey = "mcMMO: Custom Damage";
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal";
public static mcMMO p;
// Jar Stuff
public static File mcmmo;
public static FixedMetadataValue metadataValue;
/* Managers */
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static SalvageableManager salvageableManager;
private static ModManager modManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
private static HolidayManager holidayManager;
private static UpgradeManager upgradeManager;
/* Blacklist */
private static WorldBlacklist worldBlacklist;
/* File Paths */
private static String mainDirectory;
private static String flatFileDirectory;
private static String usersFile;
private static String modDirectory;
/* Plugin Checks */
private static boolean healthBarPluginEnabled;
private static boolean isRetroModeEnabled;
// MainConfig Validation Check
public boolean noErrorsInConfigFiles = true;
// XP Event Check
private boolean xpEventEnabled;
public static String getMainDirectory() {
return mainDirectory;
}
public static String getFlatFileDirectory() {
return flatFileDirectory;
}
public static String getUsersFilePath() {
return usersFile;
}
public static String getModDirectory() {
return modDirectory;
}
public static FormulaManager getFormulaManager() {
return formulaManager;
}
public static HolidayManager getHolidayManager() {
return holidayManager;
}
public static ChunkManager getPlaceStore() {
return placeStore;
}
public static RepairableManager getRepairableManager() {
return repairableManager;
}
public static SalvageableManager getSalvageableManager() {
return salvageableManager;
}
public static DatabaseManager getDatabaseManager() {
return databaseManager;
}
@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
}
public static ModManager getModManager() {
return modManager;
}
public static UpgradeManager getUpgradeManager() {
return upgradeManager;
}
public static boolean isHealthBarPluginEnabled() {
return healthBarPluginEnabled;
}
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
* Standard mode is scaled for 1-100
*
* @return true if retro mode is enabled
*/
public static boolean isRetroModeEnabled() {
return isRetroModeEnabled;
}
public static WorldBlacklist getWorldBlacklist() {
return worldBlacklist;
}
/**
* Things to be run when the plugin is enabled.
*/
@Override
public void onEnable() {
try {
p = this;
getLogger().setFilter(new LogFilter(this));
metadataValue = new FixedMetadataValue(this, true);
PluginManager pluginManager = getServer().getPluginManager();
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
upgradeManager = new UpgradeManager();
setupFilePaths();
modManager = new ModManager();
loadConfigFiles();
if (!noErrorsInConfigFiles) {
return;
}
//Store this value so other plugins can check it
isRetroModeEnabled = MainConfig.getInstance().getIsRetroMode();
if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
checkModConfigs();
}
if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
}
if (pluginManager.getPlugin("NoCheatPlus") != null && pluginManager.getPlugin("CompatNoCheatPlus") == null) {
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
}
databaseManager = DatabaseManagerFactory.getDatabaseManager();
registerEvents();
registerCoreSkills();
registerCustomRecipes();
PartyManager.loadParties();
formulaManager = new FormulaManager();
holidayManager = new HolidayManager();
for (Player player : getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
}
debug("Version " + getDescription().getVersion() + " is enabled!");
scheduleTasks();
CommandRegistrationManager.registerCommands();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (MainConfig.getInstance().getPTPCommandWorldPermissions()) {
Permissions.generateWorldTeleportPermissions();
}
//Populate Ranked Skill Maps (DO THIS LAST)
RankUtils.populateRanks();
//If anonymous statistics are enabled then use them
Metrics metrics;
if (MainConfig.getInstance().getIsMetricsEnabled()) {
metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
if (MainConfig.getInstance().getIsRetroMode())
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard"));
else
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro"));
}
} catch (Throwable t) {
getLogger().severe("There was an error while enabling mcMMO!");
if (!(t instanceof ExceptionInInitializerError)) {
t.printStackTrace();
} else {
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
}
getServer().getPluginManager().disablePlugin(this);
}
//Init the blacklist
worldBlacklist = new WorldBlacklist(this);
}
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
WorldGuardManager.getInstance().registerFlags();
}
/**
* Things to be run when the plugin is disabled.
*/
@Override
public void onDisable() {
try {
Alchemy.finishAllBrews(); // Finish all partially complete AlchemyBrewTasks to prevent vanilla brewing continuation on restart
UserManager.saveAll(); // Make sure to save player information if the server shuts down
UserManager.clearAll();
PartyManager.saveParties(); // Save our parties
//TODO: Needed?
if (MainConfig.getInstance().getScoreboardsEnabled())
ScoreboardManager.teardownAll();
formulaManager.saveFormula();
holidayManager.saveAnniversaryFiles();
placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores
} catch (NullPointerException e) {
e.printStackTrace();
}
debug("Canceling all tasks...");
getServer().getScheduler().cancelTasks(this); // This removes our tasks
debug("Unregister all events...");
HandlerList.unregisterAll(this); // Cancel event registrations
if (MainConfig.getInstance().getBackupsEnabled()) {
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
ZipLibrary.mcMMOBackup();
} catch (IOException e) {
getLogger().severe(e.toString());
} catch (Throwable e) {
if (e instanceof NoClassDefFoundError) {
getLogger().severe("Backup class not found!");
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
} else {
getLogger().severe(e.toString());
}
}
}
databaseManager.onDisable();
debug("Was disabled."); // How informative!
}
public boolean isXPEventEnabled() {
return xpEventEnabled;
}
public void setXPEventEnabled(boolean enabled) {
this.xpEventEnabled = enabled;
}
public void toggleXpEventEnabled() {
xpEventEnabled = !xpEventEnabled;
}
public void debug(String message) {
getLogger().info("[Debug] " + message);
}
/**
* Setup the various storage file paths
*/
private void setupFilePaths() {
mcmmo = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
modDirectory = mainDirectory + "mods" + File.separator;
fixFilePaths();
}
private void fixFilePaths() {
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
if (oldFlatfilePath.exists()) {
if (!oldFlatfilePath.renameTo(new File(flatFileDirectory))) {
getLogger().warning("Failed to rename FlatFileStuff to flatfile!");
}
}
if (oldModPath.exists()) {
if (!oldModPath.renameTo(new File(modDirectory))) {
getLogger().warning("Failed to rename ModConfigs to mods!");
}
}
File oldArmorFile = new File(modDirectory + "armor.yml");
File oldBlocksFile = new File(modDirectory + "blocks.yml");
File oldEntitiesFile = new File(modDirectory + "entities.yml");
File oldToolsFile = new File(modDirectory + "tools.yml");
if (oldArmorFile.exists()) {
if (!oldArmorFile.renameTo(new File(modDirectory + "armor.default.yml"))) {
getLogger().warning("Failed to rename armor.yml to armor.default.yml!");
}
}
if (oldBlocksFile.exists()) {
if (!oldBlocksFile.renameTo(new File(modDirectory + "blocks.default.yml"))) {
getLogger().warning("Failed to rename blocks.yml to blocks.default.yml!");
}
}
if (oldEntitiesFile.exists()) {
if (!oldEntitiesFile.renameTo(new File(modDirectory + "entities.default.yml"))) {
getLogger().warning("Failed to rename entities.yml to entities.default.yml!");
}
}
if (oldToolsFile.exists()) {
if (!oldToolsFile.renameTo(new File(modDirectory + "tools.default.yml"))) {
getLogger().warning("Failed to rename tools.yml to tools.default.yml!");
}
}
File currentFlatfilePath = new File(flatFileDirectory);
currentFlatfilePath.mkdirs();
}
private void loadConfigFiles() {
// Force the loading of config files
TreasureConfig.getInstance();
ChunkConversionOptions.getInstance();
AdvancedConfig.getInstance();
PotionConfig.getInstance();
CoreSkillsConfig.getInstance();
SoundConfig.getInstance();
RankConfig.getInstance();
new ChildConfig();
List<Repairable> repairables = new ArrayList<Repairable>();
List<Salvageable> salvageables = new ArrayList<Salvageable>();
if (MainConfig.getInstance().getToolModsEnabled()) {
new ToolConfigManager(this);
}
if (MainConfig.getInstance().getArmorModsEnabled()) {
new ArmorConfigManager(this);
}
if (MainConfig.getInstance().getBlockModsEnabled()) {
new BlockConfigManager(this);
}
if (MainConfig.getInstance().getEntityModsEnabled()) {
new EntityConfigManager(this);
}
// Load repair configs, make manager, and register them at this time
repairables.addAll(new RepairConfigManager(this).getLoadedRepairables());
repairables.addAll(modManager.getLoadedRepairables());
repairableManager = new SimpleRepairableManager(repairables.size());
repairableManager.registerRepairables(repairables);
// Load salvage configs, make manager and register them at this time
SalvageConfigManager sManager = new SalvageConfigManager(this);
salvageables.addAll(sManager.getLoadedSalvageables());
salvageableManager = new SimpleSalvageableManager(salvageables.size());
salvageableManager.registerSalvageables(salvageables);
}
private void registerEvents() {
PluginManager pluginManager = getServer().getPluginManager();
// Register events
pluginManager.registerEvents(new PlayerListener(this), this);
pluginManager.registerEvents(new BlockListener(this), this);
pluginManager.registerEvents(new EntityListener(this), this);
pluginManager.registerEvents(new InventoryListener(this), this);
pluginManager.registerEvents(new SelfListener(this), this);
pluginManager.registerEvents(new WorldListener(this), this);
}
/**
* Registers core skills
* This enables the skills in the new skill system
*/
private void registerCoreSkills() {
/*
* Acrobatics skills
*/
if (CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) {
System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
//TODO: Should do this differently
Roll roll = new Roll();
CoreSkillsConfig.getInstance().isSkillEnabled(roll);
InteractionManager.registerSubSkill(new Roll());
}
}
private void registerCustomRecipes() {
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (MainConfig.getInstance().getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
}, 40);
}
private void scheduleTasks() {
// Periodic save timer (Saves every 10 minutes by default)
long saveIntervalTicks = MainConfig.getInstance().getSaveInterval() * 1200;
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
// Cleanup the backups folder
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
// Bleed timer (Runs every 0.5 seconds)
new BleedTimerTask().runTaskTimer(this, 1 * Misc.TICK_CONVERSION_FACTOR, 1 * (Misc.TICK_CONVERSION_FACTOR / 2));
// Old & Powerless User remover
long purgeIntervalTicks = MainConfig.getInstance().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (purgeIntervalTicks == 0) {
new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} else if (purgeIntervalTicks > 0) {
new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
long kickIntervalTicks = MainConfig.getInstance().getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
}
// Update power level tag scoreboards
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
if (getHolidayManager().nearingAprilFirst()) {
new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 1L * 60L * 60L * Misc.TICK_CONVERSION_FACTOR);
}
// Clear the registered XP data so players can earn XP again
if (ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60);
}
}
private void checkModConfigs() {
if (!MainConfig.getInstance().getToolModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom tool config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
}
if (!MainConfig.getInstance().getArmorModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom armor config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
}
if (!MainConfig.getInstance().getBlockModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom block config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
}
if (!MainConfig.getInstance().getEntityModsEnabled()) {
getLogger().warning("Cauldron implementation found, but the custom entity config for mcMMO is disabled!");
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}
public InputStreamReader getResourceAsReader(String fileName) {
InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
}
}

View File

@@ -1,624 +0,0 @@
package util.java.mcMMO;
import org.bukkit.Material;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class PotionConfigGenerator {
public static void main(String[] args) {
Map<WriteablePotion, Map<Ingredient, WriteablePotion>> vanillaPotions = new HashMap<>();
populateVanillaPotions(vanillaPotions);
Map<WriteablePotion, Map<Ingredient, WriteablePotion>> mcMMOPotions = new HashMap<>();
populateCustomPotions(mcMMOPotions);
List<WriteablePotion> sorted = new ArrayList<>();
sorted.addAll(vanillaPotions.keySet());
sorted.addAll(mcMMOPotions.keySet());
sorted.sort((a, b) -> {
// All normal potions first
if (a.mat == Material.POTION && b.mat != Material.POTION) {
return -1;
}
if (b.mat == Material.POTION && a.mat != Material.POTION) {
return 1;
}
// All splash potions second
if (a.mat == Material.SPLASH_POTION && b.mat != Material.SPLASH_POTION) {
return -1;
}
if (b.mat == Material.SPLASH_POTION && a.mat != Material.SPLASH_POTION) {
return 1;
}
// Vanilla Potions first
if (a.effect == null && b.effect != null) {
return -1;
}
if (b.effect == null && a.effect != null) {
return 1;
}
// Vanilla potions
if (a.effect == null && b.effect == null) {
// Order by PotionType
if (a.data.getType() != b.data.getType()) {
return Integer.compare(a.data.getType().ordinal(), b.data.getType().ordinal());
}
// Plain before extended or upgraded
if (!a.data.isExtended() && !a.data.isUpgraded() && (b.data.isExtended() || b.data.isUpgraded())) {
return -1;
}
if (!b.data.isExtended() && !b.data.isUpgraded() && (a.data.isExtended() || a.data.isUpgraded())) {
return 1;
}
// Extended before Upgraded
if (a.data.isExtended() && b.data.isUpgraded()) {
return -1;
}
if (b.data.isExtended() && a.data.isUpgraded()) {
return -1;
}
// Same potion somehow?
return 0;
}
// mcMMO Potions
else {
if ((a.baseName.contains("II") || a.baseName.contains("EXTENDED")) && !(b.baseName.contains("II") || b.baseName.contains("EXTENDED"))) {
return 1;
}
if ((b.baseName.contains("II") || b.baseName.contains("EXTENDED")) && !(a.baseName.contains("II") || a.baseName.contains("EXTENDED"))) {
return -1;
}
if (!a.baseName.contains("II") && b.baseName.contains("II")) {
return -1;
}
if (!b.baseName.contains("II") && a.baseName.contains("II")) {
return 1;
}
return a.baseName.split("_")[0].compareTo(b.baseName.split("_")[0]);
}
});
for (WriteablePotion potion : sorted) {
System.out.println(" " + potion.name + ":");
Map<Ingredient, WriteablePotion> children;
if (vanillaPotions.containsKey(potion)) {
children = vanillaPotions.get(potion);
} else {
System.out.println(" Name: " + prettify(potion.name));
children = mcMMOPotions.get(potion);
}
System.out.println(" Material: " + potion.mat.name());
System.out.println(" PotionData:");
System.out.println(" PotionType: " + potion.data.getType().name());
if (potion.data.isExtended()) {
System.out.println(" Extended: true");
}
if (potion.data.isUpgraded()) {
System.out.println(" Upgraded: true");
}
if (potion.effect != null) {
System.out.println(" Effects: [\"" + getName(potion.effect.getType()) + " " + potion.effect.getAmplifier() + " " + potion.effect.getDuration() + "\"]");
}
if (children == null || children.isEmpty()) {
continue;
}
System.out.println(" Children:");
for (Entry<Ingredient, WriteablePotion> child : children.entrySet()) {
System.out.println(" " + child.getKey().name + ": " + child.getValue().name);
}
}
}
private static String prettify(String name) {
String[] substrings = name.split("_");
String prettyString = "";
int size = 1;
for (String string : substrings) {
prettyString = prettyString.concat(getCapitalized(string));
if (size < substrings.length) {
prettyString = prettyString.concat(" ");
}
size++;
}
return prettyString;
}
public static String getCapitalized(String target) {
if (target.equals("II")) { // hacks
return target;
}
return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
}
private static String getName(PotionEffectType type) {
switch (type.getId()) {
case 1:
return "SPEED";
case 2:
return "SLOW";
case 3:
return "FAST_DIGGING";
case 4:
return "SLOW_DIGGING";
case 5:
return "INCREASE_DAMAGE";
case 6:
return "HEAL";
case 7:
return "HARM";
case 8:
return "JUMP";
case 9:
return "CONFUSION";
case 10:
return "REGENERATION";
case 11:
return "DAMAGE_RESISTANCE";
case 12:
return "FIRE_RESISTANCE";
case 13:
return "WATER_BREATHING";
case 14:
return "INVISIBILITY";
case 15:
return "BLINDNESS";
case 16:
return "NIGHT_VISION";
case 17:
return "HUNGER";
case 18:
return "WEAKNESS";
case 19:
return "POISON";
case 20:
return "WITHER";
case 21:
return "HEALTH_BOOST";
case 22:
return "ABSORPTION";
case 23:
return "SATURATION";
case 24:
return "GLOWING";
case 25:
return "LEVITATION";
case 26:
return "LUCK";
case 27:
return "UNLUCK";
case 28:
return "SLOW_FALLING";
case 29:
return "CONDUIT_POWER";
case 30:
return "DOLPHINS_GRACE";
default:
return "UNKNOWN_EFFECT_TYPE_" + type.getId();
}
}
private static void populateVanillaPotions(Map<WriteablePotion, Map<Ingredient, WriteablePotion>> vanillaPotions) {
for (PotionType type : PotionType.values()) {
for (Material material : new Material[]{Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION}) {
WriteablePotion data = new WriteablePotion(material, type);
HashMap<Ingredient, WriteablePotion> children = new HashMap<>();
getChildren(data, children);
vanillaPotions.put(data, children);
if (type.isExtendable()) {
data = new WriteablePotion(material, new PotionData(type, true, false));
children = new HashMap<>();
getChildren(data, children);
vanillaPotions.put(data, children);
}
if (type.isUpgradeable()) {
data = new WriteablePotion(material, new PotionData(type, false, true));
children = new HashMap<>();
getChildren(data, children);
vanillaPotions.put(data, children);
}
}
}
for (Entry<WriteablePotion, Map<Ingredient, WriteablePotion>> entry : vanillaPotions.entrySet()) {
if (entry.getKey().mat == Material.POTION) {
entry.getValue().put(new Ingredient(Material.GUNPOWDER), new WriteablePotion(Material.SPLASH_POTION, entry.getKey().data));
}
if (entry.getKey().mat == Material.SPLASH_POTION) {
entry.getValue().put(new Ingredient(Material.DRAGON_BREATH), new WriteablePotion(Material.LINGERING_POTION, entry.getKey().data));
}
}
}
private static void getChildren(WriteablePotion current, HashMap<Ingredient, WriteablePotion> children) {
switch (current.data.getType()) {
case WATER:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.NETHER_WART), new WriteablePotion(current.mat, PotionType.AWKWARD));
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.WEAKNESS));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, PotionType.THICK));
children.put(new Ingredient(Material.BLAZE_POWDER), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.SUGAR), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.SPIDER_EYE), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.MUNDANE));
return;
case AWKWARD:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.GOLDEN_CARROT), new WriteablePotion(current.mat, PotionType.NIGHT_VISION));
children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.JUMP));
children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.FIRE_RESISTANCE));
children.put(new Ingredient(Material.SUGAR), new WriteablePotion(current.mat, PotionType.SPEED));
children.put(new Ingredient(Material.PUFFERFISH), new WriteablePotion(current.mat, PotionType.WATER_BREATHING));
children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new WriteablePotion(current.mat, PotionType.INSTANT_HEAL));
children.put(new Ingredient(Material.SPIDER_EYE), new WriteablePotion(current.mat, PotionType.POISON));
children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.REGEN));
children.put(new Ingredient(Material.BLAZE_POWDER), new WriteablePotion(current.mat, PotionType.STRENGTH));
children.put(new Ingredient(Material.TURTLE_HELMET), new WriteablePotion(current.mat, PotionType.TURTLE_MASTER));
children.put(new Ingredient(Material.PHANTOM_MEMBRANE), new WriteablePotion(current.mat, PotionType.SLOW_FALLING));
// mcMMO custom potions
double mod = 1;
if (current.mat == Material.SPLASH_POTION) {
mod = 0.75;
}
if (current.mat == Material.LINGERING_POTION) {
mod = 0.25;
}
children.put(new Ingredient(Material.BROWN_MUSHROOM), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.CONFUSION, (int) (450 * mod), 0), "NAUSEA"));
children.put(new Ingredient(Material.CARROT), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.FAST_DIGGING, (int) (3600 * mod), 0), "HASTE"));
children.put(new Ingredient(Material.SLIME_BALL), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SLOW_DIGGING, (int) (3600 * mod), 0), "DULLNESS"));
children.put(new Ingredient(Material.GOLDEN_APPLE), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (int) (450 * mod), 0), "RESISTANCE"));
children.put(new Ingredient(Material.INK_SAC), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.BLINDNESS, (int) (225 * mod), 0), "BLINDNESS"));
children.put(new Ingredient(Material.ROTTEN_FLESH), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HUNGER, (int) (900 * mod), 0), "HUNGER"));
children.put(new Ingredient(Material.POISONOUS_POTATO), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.WITHER, (int) (450 * mod), 0), "DECAY"));
children.put(new Ingredient(Material.QUARTZ), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.ABSORPTION, (int) (1800 * mod), 0), "ABSORPTION"));
children.put(new Ingredient(Material.FERN), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION"));
children.put(new Ingredient(Material.APPLE), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST"));
return;
case FIRE_RESISTANCE:
assert (!current.data.isUpgraded());
if (current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
} else {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case INSTANT_DAMAGE:
assert (!current.data.isExtended());
if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
}
return;
case INSTANT_HEAL:
assert (!current.data.isExtended());
if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
} else {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
}
return;
case INVISIBILITY:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case JUMP:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case NIGHT_VISION:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INVISIBILITY));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} else {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INVISIBILITY, true, false)));
}
return;
case POISON:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} else {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
}
return;
case REGEN:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SLOWNESS:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SLOW_FALLING:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case SPEED:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} else {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
}
return;
case STRENGTH:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case TURTLE_MASTER:
if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case WATER_BREATHING:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case WEAKNESS:
assert (!current.data.isUpgraded());
if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
}
return;
case LUCK:
case MUNDANE:
case THICK:
case UNCRAFTABLE:
assert (!current.data.isExtended());
assert (!current.data.isUpgraded());
return;
default:
assert (false);
break;
}
}
private static void populateCustomPotions(Map<WriteablePotion, Map<Ingredient, WriteablePotion>> mcMMOPotions) {
for (Material material : new Material[]{Material.POTION, Material.SPLASH_POTION, Material.LINGERING_POTION}) {
WriteablePotion data;
double mod = 1;
if (material == Material.SPLASH_POTION) {
mod = 0.75;
}
if (material == Material.LINGERING_POTION) {
mod = 0.25;
}
HashMap<Ingredient, WriteablePotion> children;
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.CONFUSION, (int) (450 * mod), 0), "NAUSEA");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.FAST_DIGGING, (int) (3600 * mod), 0), "HASTE");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SLOW_DIGGING, (int) (3600 * mod), 0), "DULLNESS");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, (int) (450 * mod), 0), "RESISTANCE");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.BLINDNESS, (int) (225 * mod), 0), "BLINDNESS");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HUNGER, (int) (900 * mod), 0), "HUNGER");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.WITHER, (int) (450 * mod), 0), "DECAY");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.ABSORPTION, (int) (1800 * mod), 0), "ABSORPTION");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
data = new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST");
children = new HashMap<>();
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() / 2, 1), data.baseName + "_II"));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(material, PotionType.UNCRAFTABLE, new PotionEffect(data.effect.getType(), data.effect.getDuration() * 2, 0), data.baseName + "_EXTENDED"));
for (WriteablePotion child : children.values()) {
mcMMOPotions.put(child, new HashMap<>());
}
mcMMOPotions.put(data, children);
}
// Add all material state changes
for (Entry<WriteablePotion, Map<Ingredient, WriteablePotion>> entry : mcMMOPotions.entrySet()) {
if (entry.getKey().mat == Material.POTION) {
PotionEffect effect = new PotionEffect(entry.getKey().effect.getType(), (int) (entry.getKey().effect.getDuration() * 0.75), entry.getKey().effect.getAmplifier());
entry.getValue().put(new Ingredient(Material.GUNPOWDER), new WriteablePotion(Material.SPLASH_POTION, entry.getKey().data, effect, entry.getKey().baseName));
} else if (entry.getKey().mat == Material.SPLASH_POTION) {
PotionEffect effect = new PotionEffect(entry.getKey().effect.getType(), (int) (entry.getKey().effect.getDuration() * 0.33), entry.getKey().effect.getAmplifier());
entry.getValue().put(new Ingredient(Material.DRAGON_BREATH), new WriteablePotion(Material.LINGERING_POTION, entry.getKey().data, effect, entry.getKey().baseName));
}
}
}
public static class Ingredient {
public Material mat;
public int data;
public String name;
public Ingredient(Material mat) {
this.mat = mat;
this.data = 0;
name = mat.name();
}
}
public static class WriteablePotion {
public String name;
public Material mat;
public PotionData data;
public PotionEffect effect;
public String baseName;
public WriteablePotion(PotionData data) {
this(Material.POTION, data);
}
public WriteablePotion(Material type, PotionData data) {
this(type, data, null, getMCName(data.getType()));
}
public WriteablePotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
this(mat, new PotionData(type, false, false), effect, baseName);
}
public WriteablePotion(Material type, PotionData data, PotionEffect effect, String baseName) {
this.data = data;
this.effect = effect;
this.mat = type;
this.baseName = baseName;
this.name = "POTION_OF_" + baseName;
if (mat == Material.SPLASH_POTION) {
this.name = "SPLASH_" + this.name;
}
if (mat == Material.LINGERING_POTION) {
this.name = "LINGERING_" + this.name;
}
if (data.isExtended()) {
this.name += "_EXTENDED";
}
if (data.isUpgraded()) {
this.name += "_II";
}
}
public WriteablePotion(PotionType type) {
this(new PotionData(type, false, false));
}
public WriteablePotion(Material mat, PotionType type) {
this(mat, new PotionData(type, false, false));
}
private static String getMCName(PotionType type) {
switch (type) {
case INSTANT_DAMAGE:
return "HARMING";
case INSTANT_HEAL:
return "HEALING";
case JUMP:
return "LEAPING";
case REGEN:
return "REGENERATION";
case SPEED:
return "SWIFTNESS";
case UNCRAFTABLE:
return "EMPTY";
case LUCK:
case MUNDANE:
case NIGHT_VISION:
case POISON:
case INVISIBILITY:
case SLOWNESS:
case AWKWARD:
case STRENGTH:
case THICK:
case FIRE_RESISTANCE:
case WATER:
case WATER_BREATHING:
case WEAKNESS:
case TURTLE_MASTER:
case SLOW_FALLING:
return type.name();
default:
return "";
}
}
public int hashCode() {
return name.hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof WriteablePotion)) {
return false;
}
return name.equals(((WriteablePotion) obj).name);
}
}
}

View File

@@ -1,3 +0,0 @@
Manifest-Version: 1.0
Main-Class: com.gmail.nossr50.mcMMO

View File

@@ -1,586 +0,0 @@
#
# Advanced configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# For advanced users only! There is no need to change anything here.
#
# You can customize almost every aspect of every skill here.
# Its mainly here if you've customized the experience formula.
# Configure at what level you get better with certain abilities.
#
#####
#
# Settings for the Skills
###
# Enables anonymous statistics
Metrics:
bstats: true
Feedback:
SkillCommand:
BlankLinesAboveHeader: true
# If sendtitles is true messages will be sent using the title api (BIG TEXT ON SCREEN)
Events:
XP:
SendTitles: true
#The actionbar is the message location right above the health bar
## If you disable the action bar messages, mcMMO will send the message to the chat system instead
ActionBarNotifications:
AbilityOff:
Enabled: true
SendCopyOfMessageToChat: false
HardcoreMode:
Enabled: true
SendCopyOfMessageToChat: true
RequirementsNotMet:
Enabled: true
SendCopyOfMessageToChat: false
AbilityCoolDown:
Enabled: true
SendCopyOfMessageToChat: false
LevelUps:
Enabled: true
SendCopyOfMessageToChat: true
Holiday:
Enabled: true
SendCopyOfMessageToChat: true
ToolReady:
Enabled: true
SendCopyOfMessageToChat: false
SubSkillInteraction:
Enabled: true
SendCopyOfMessageToChat: false
SubSkillFailed:
Enabled: false
SendCopyOfMessageToChat: true
SubSkillUnlocked:
Enabled: true
SendCopyOfMessageToChat: true
SuperAbilityInteraction:
Enabled: true
SendCopyOfMessageToChat: false
SuperAbilityAlertOthers:
Enabled: true
SendCopyOfMessageToChat: true
ExperienceGain:
Enabled: true
SendCopyOfMessageToChat: false
ItemMessage:
Enabled: true
SendCopyOfMessageToChat: false
NoPermission:
Enabled: true
SendCopyOfMessageToChat: true
PartyMessage:
Enabled: true
SendCopyOfMessageToChat: true
Skills:
General:
StartingLevel: 1
Ability:
Length:
Standard:
CapLevel: 50
IncreaseLevel: 5
RetroMode:
CapLevel: 500
IncreaseLevel: 50
EnchantBuff: 5
# IncreaseLevel: This setting will determine when the length of every ability gets longer with 1 second
# EnchantBuff: This setting determines how many enchant levels to use when buffing Super Breaker & Giga Drill Breaker
#
# Settings for Acrobatics
###
Acrobatics:
Dodge:
# ChanceMax: Maximum chance of dodging when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level or higher, the dodge chance will not go higher than <ChanceMax>
# DamageModifier: Dodge damage will be divided by this modifier
ChanceMax: 20.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
DamageModifier: 2.0
Roll:
# ChanceMax: Maximum chance of rolling when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level or higher, the roll chance will not go higher than <ChanceMax>
# DamageThreshold: The max damage a player can negate with a roll, graceful roll doubles this number
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
DamageThreshold: 7.0
#
# Settings for Alchemy
###
Alchemy:
Catalysis:
# MaxBonusLevel: Maximum bonus level of Catalysis, when a player reaches this level his brewing speed will be <MaxSpeed>
# MinSpeed: Minimum brewing speed allowed when at <UnlockLevel> or lower
# MaxSpeed: Maximum brewing speed allowed when at <MaxBonusLevel> or higher
MaxBonusLevel:
Standard: 100
RetroMode: 1000
MinSpeed: 1.0
MaxSpeed: 4.0
#
# Settings for Archery
###
Archery:
SkillShot:
# RankDamageMultiplier: The current rank of this subskill is multiplied by this value to determine the bonus damage, rank 20 would result in 200% damage increase with a value of 10.0 for RankDamageMultiplier
# RankDamageMultiplier is a percentage
RankDamageMultiplier: 10.0
# MaxDamage: After adding bonus damage, the total damage dealt by the player will not exceed this number
# You should be careful to not set this too low
MaxDamage: 9.0
Daze:
# ChanceMax: Maximum chance of causing daze to opponents when on <MaxBonusLevel> or higher
# MaxBonusLevel: Maximum bonus level of Daze, when a player reaches this level his chance of causing a daze will be <ChanceMax>
# Modifier: Extra damage for arrows that cause a daze (2 damage = 1 heart)
ChanceMax: 50.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
BonusDamage: 4.0
ArrowRetrieval:
# ChanceMax: Maximum chance of retrieving arrows when on <MaxBonusLevel> or higher
# MaxBonusLevel: Maximum bonus level for Arrow retrieval, at this level the chance of retrieving arrows from mobs is <ChanceMax>
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# ForceMultiplier: Multiply the force of the bow by this for an XP boost.
ForceMultiplier: 2.0
#
# Settings for Axes
###
Axes:
AxeMastery:
# This number is multiplied by the current rank the player has in this subskill to find the amount of additional damage to apply
# With the default config value of 1.0, at rank 4 a player will deal 4.0 extra damage with Axes (1.0 * 4)
RankDamageMultiplier: 1.0
CriticalStrikes:
# ChanceMax: Maximum chance of causing a critical hit when on <MaxBonusLevel> or higher
# MaxBonusLevel: Level where <ChanceMax> of causing critical hits is reached
ChanceMax: 37.50
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# Damage modifier of critical hits for PVP / PVE, when causing a critical hit the damage gets multiplied by the modifier
PVP_Modifier: 1.5
PVE_Modifier: 2.0
GreaterImpact:
# Chance: Chance of hitting with GreaterImpact, mobs are knocked backwards when successful
# KnockbackModifier: Velocity modifier of GreaterImpact hits, this determines how great the knockback is
# BonusDamage: Extra damage for GreaterImpact hits
Chance: 25.0
KnockbackModifier: 1.5
BonusDamage: 2.0
ArmorImpact:
# IncreaseLevel: Every <IncreaseLevel> the durability damage goes up with 1
# Chance: Chance of hitting with ArmorImpact
# MaxPercentageDurabilityDamage: Durability damage cap for ArmorImpact, 20% means that you can never destroy a piece of armor in less than 5 hits
IncreaseLevel: 5
Chance: 25.0
MaxPercentageDurabilityDamage: 20.0
SkullSplitter:
# DamageModifier: Damage will get divided by this modifier
DamageModifier: 2.0
#
# Settings for Fishing
###
Fishing:
ShakeChance:
Rank_1: 15.0
Rank_2: 15.0
Rank_3: 25.0
Rank_4: 35.0
Rank_5: 45.0
Rank_6: 55.0
Rank_7: 65.0
Rank_8: 75.0
# VanillaXPMultiplier: Vanilla XP gained from fishing is multiplied by these values.
VanillaXPMultiplier:
Rank_1: 1
Rank_2: 2
Rank_3: 3
Rank_4: 3
Rank_5: 4
Rank_6: 4
Rank_7: 5
Rank_8: 5
FishermansDiet:
# This determines when Fisherman's Diet adds extra hunger recovery to food
RankChange: 20
MasterAngler:
# BoatMultiplier: Catch rate is multiplied by this modifier
# BiomeModifier: Catch rate is multiplied by this modifier
BoatModifier: 2.0
BiomeModifier: 2.0
#
# Settings for Herbalism
###
Herbalism:
GreenThumb:
# ChanceMax: Maximum chance of GreenThumb when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level, GreenThumb chance will be <ChanceMax>
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
DoubleDrops:
# ChanceMax: Maximum chance of receiving double drops when on <MaxBonusLevel> or higher
# MaxBonusLevel: Level when <ChanceMax> of receiving double drops is reached
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
HylianLuck:
# ChanceMax: Maximum chance of Hylian Luck when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level, Hylian Luck chance will be <ChanceMax>
ChanceMax: 10.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
ShroomThumb:
# ChanceMax: Maximum chance of ShroomThumb when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level, ShroomThumb chance will be <ChanceMax>
ChanceMax: 50.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
#
# Settings for Mining
###
Mining:
DoubleDrops:
# ChanceMax: Maximum chance of receiving double drops when on <MaxBonusLevel> or higher
# MaxBonusLevel: Level when <ChanceMax> of receiving double drops is reached
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
BlastMining:
# BlastDamageDecrease Ranks: % of damage reduced from TNT explosions
BlastDamageDecrease:
Rank_1: 0.0
Rank_2: 0.0
Rank_3: 0.0
Rank_4: 25.0
Rank_5: 25.0
Rank_6: 50.0
Rank_7: 50.0
Rank_8: 100.0
# OreBonus Ranks: % of extra ores received when Blast Mining
OreBonus:
Rank_1: 35.0
Rank_2: 40.0
Rank_3: 45.0
Rank_4: 50.0
Rank_5: 55.0
Rank_6: 60.0
Rank_7: 65.0
Rank_8: 70.0
# DebrisReduction_Rank: % of fewer non-ores received when Blast Mining
DebrisReduction:
Rank_1: 10.0
Rank_2: 20.0
Rank_3: 30.0
Rank_4: 30.0
Rank_5: 30.0
Rank_6: 30.0
Rank_7: 30.0
Rank_8: 30.0
# DropMultiplier Ranks: # of times each ore will drop
DropMultiplier:
Rank_1: 1
Rank_2: 1
Rank_3: 1
Rank_4: 1
Rank_5: 2
Rank_6: 2
Rank_7: 3
Rank_8: 3
# BlastRadiusModifier Ranks: Increases the blast radius by this amount
BlastRadiusModifier:
Rank_1: 1.0
Rank_2: 1.0
Rank_3: 2.0
Rank_4: 2.0
Rank_5: 3.0
Rank_6: 3.0
Rank_7: 4.0
Rank_8: 4.0
#
# Settings for Repair
###
Repair:
RepairMastery:
# MaxBonusPercentage: Maximum bonus percentage for Repair Mastery
# MaxBonusLevel: On this level, the maximum bonus is reached
MaxBonusPercentage: 200.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
SuperRepair:
# ChanceMax: Maximum chance of Super Repair when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level, Super Repair chance will be <ChanceMax>
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
ArcaneForging:
May_Lose_Enchants: true
Keep_Enchants_Chance:
Rank_1: 10.0
Rank_2: 20.0
Rank_3: 30.0
Rank_4: 40.0
Rank_5: 50.0
Rank_6: 50.0
Rank_7: 60.0
Rank_8: 60.0
Downgrades_Enabled: true
Downgrades_Chance:
Rank_1: 75.0
Rank_2: 50.0
Rank_3: 40.0
Rank_4: 30.0
Rank_5: 25.0
Rank_6: 20.0
Rank_7: 15.0
Rank_8: 10.0
#
# Settings for Salvage
###
Salvage:
ArcaneSalvage:
# EnchantLossEnabled: When salvaging enchanted items, the enchants may be lost
# EnchantDowngradeEnabled: When salvaging enchanted items, the enchants may be downgraded
EnchantLossEnabled: true
EnchantDowngradeEnabled: true
# ExtractFullEnchant: Chance to extract the full enchant at each ArcaneSalvage rank
ExtractFullEnchant:
Rank_1: 2.5
Rank_2: 5.0
Rank_3: 7.5
Rank_4: 10.0
Rank_5: 12.5
Rank_6: 17.5
Rank_7: 25.0
Rank_8: 32.5
# ExtractPartialEnchant: Chance to extract the partial enchant at each ArcaneSalvage rank
ExtractPartialEnchant:
Rank_1: 2.0
Rank_2: 2.5
Rank_3: 5.0
Rank_4: 7.5
Rank_5: 10.0
Rank_6: 12.5
Rank_7: 15.0
Rank_8: 17.5
#
# Settings for Smelting
###
Smelting:
FuelEfficiency:
# Multiplier: The furnace burn time will be multiplied by this value.
# MaxBonusLevel: On this level, the efficiency multiplier will stop increasing
Multiplier: 3.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
SecondSmelt:
# ChanceMax: Maximum chance of triggering Second Smelt
# MaxBonusLevel: On this level, the chance to cause Second Smelt will be <ChanceMax>
ChanceMax: 50.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
FluxMining:
# Chance: Chance for Flux Mining to activate
Chance: 33.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# VanillaXPMultiplier: Vanilla XP gained from smelting ores is multiplied by these values.
VanillaXPMultiplier:
Rank_1: 1
Rank_2: 2
Rank_3: 3
Rank_4: 3
Rank_5: 4
Rank_6: 4
Rank_7: 5
Rank_8: 5
#
# Settings for Swords
###
Swords:
Rupture:
# ChanceMax: Maximum chance of triggering bleeding
# MaxBonusLevel: On this level, the chance to cause Bleeding will be <ChanceMax>
ChanceMax: 33.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# DamagePlayer: Bleeding damage dealt to players
# DamageMobs: Bleeding damage dealt to mobs
DamagePlayer: 2.0
DamageMobs: 3.0
# These settings determine how long the Bleeding effect lasts
MaxTicks: 8
BaseTicks: 2
CounterAttack:
# ChanceMax: Maximum chance of triggering a counter attack
# MaxBonusLevel: On this level, the chance to Counter will be <ChanceMax>
ChanceMax: 30.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# DamageModifier: Damaged caused by the damager will get divided by this modifier and dealt back to the damager
DamageModifier: 2.0
SerratedStrikes:
# DamageModifier: Damage will get divided by this modifier
# BleedTicks: This determines how long the bleeding effect of SerratedStrikes lasts
DamageModifier: 4.0
BleedTicks: 5
#
# Settings for Taming
###
Taming:
Gore:
# ChanceMax: Maximum chance of triggering gore
# MaxBonusLevel: On this level, the chance to cause Gore will be <ChanceMax>
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
# Modifier: Damage will get multiplied by this modifier
Modifier: 2.0
FastFoodService:
# Chance: The chance for wolves to heal hp when inflicting damage
Chance: 50.0
EnvironmentallyAware:
ThickFur:
# Modifier: Damage will get divided by this modifier
Modifier: 2.0
ShockProof:
# Modifier: Damage will get divided by this modifier
Modifier: 6.0
SharpenedClaws:
# Bonus: This bonus will get added to the damage caused
Bonus: 2.0
CallOfTheWild:
# MinHorseJumpStrength: The minimum jump strength a summoned horse must have
# MaxHorseJumpStrength: The maximum jump strength a summoned horse can have
MinHorseJumpStrength: 0.7
MaxHorseJumpStrength: 2.0
Pummel:
# ChanceMax: Maximum chance of triggering pummel
Chance: 10.0
#
# Settings for Unarmed
###
Unarmed:
Disarm:
# ChanceMax: Maximum chance of disarming other players
# MaxBonusLevel: Level when the maximum chance to disarm is reached
# AntiTheft: Determines if only the disarmed player can retrieve disarmed items
ChanceMax: 33.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
AntiTheft: false
ArrowDeflect:
# ChanceMax: Maximum chance of deflecting arrows
# MaxBonusLevel: Level when the maximum chance to deflect is reached
ChanceMax: 50.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
IronGrip:
# ChanceMax: Maximum chance of preventing being disarmed
# MaxBonusLevel: Level when the maximum chance to prevent being disarmed is reached
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000
IronArmStyle:
# BonusMin: Minimum bonus damage for unarmed
# BonusMax: Maximum bonus damage for unarmed
# IncreaseLevel: Bonus damage increases every increase level
IncreaseLevel: 10
#
# Settings for Woodcutting
###
Woodcutting:
TreeFeller:
# If set to true then tree feller will not use the new system and will use its old behaviour
Classic: false
# This is the time in seconds to build a new charge of Tree Feller
ChargeRate: 600
Rank_Levels:
Rank_1:
TreeSizeMax: 100
Charges: 1
Rank_2:
TreeSizeMax: 200
Charges: 1
Rank_3:
TreeSizeMax: 200
Charges: 2
Rank_4:
TreeSizeMax: 200
Charges: 3
Rank_5:
TreeSizeMax: 500
Charges: 3
# Double Drops
HarvestLumber:
# ChanceMax & MaxBonusLevel are only used for Classic, I'll make that more clear in the future.
# ChanceMax: Maximum chance of receiving double drops (100 = 100%)
# MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
ChanceMax: 100.0
MaxBonusLevel:
Standard: 100
RetroMode: 1000

View File

@@ -1,535 +0,0 @@
#
# mcMMO configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
#####
#
# Settings for mcMMO in general
###
General:
# Turning this on will scale mcMMO around 1-1000 with default scaling factor
# Everything in your config related to skill level requirements, skill level bonuses, etc will be multiplied by 10 when this mode is on
# This change is purely cosmetic, it retains the old feel of mcMMO where you could level up thousands of times
RetroMode:
Enabled: false
Locale: en_US
MOTD_Enabled: true
# Send a message to the player when his profile was successfully loaded
Show_Profile_Loaded: false
# Amount of time (in minutes) to wait between saves of player information
Save_Interval: 10
# Allow mcMMO to report on basic anonymous usage
Stats_Tracking: true
# Allow mcMMO to check if a new version is available
Update_Check: true
Prefer_Beta: false
Power_Level_Cap: 0
# Should mcMMO truncate levels if you lower your max level cap for a skillname
TruncateSkills: true
# Should mcMMO print out debug messages?
Verbose_Logging: false
# Should mcMMO over-write configs to update, or make new ones ending in .new?
Config_Update_Overwrite: true
# Play level-up sounds
LevelUp_Sounds: true
# This should fix blocks being broken client side, but not server-side.
# Enable to refresh the chunks around a player at the end of Super Breaker,
# Giga Drill Breaker, and Berserk. Resource intensive for larger servers.
Refresh_Chunks: false
#
# Settings for the mcMMO scoreboards
###
Scoreboard:
# Set this to true to enable scoreboards
UseScoreboards: false
# Display player's power levels below their names?
Power_Level_Tags: false
# Allow players to use "/mcscoreboard keep" to keep the scoreboard up
Allow_Keep: true
# Show the /mcstats scoreboard automatically after logging in
Show_Stats_After_Login: false
# Show scoreboard tips 5 times. Tips are only displayed once for every login session.
# Set to 0 to never show these tips.
Tips_Amount: 5
# Add some more color on the board :-)
Rainbows: false
# Display ability names?
Ability_Names: true
# Settings for each type of scoreboard
# Print: Should the command output be printed in chat?
# Board: Should the command output be displayed in the scoreboard sidebar?
# Display_Time: Amount of time (seconds) to display in the sidebar before clearing.
# To display permanently, use "/mcscoreboard keep" or set to -1
Types:
# Settings for /mcrank
# The sub-options (Print, Board, Display_Time) are the same for each type.
Rank:
Print: false
Board: true
Display_Time: 15
# Settings for /mctop
Top:
Print: true
Board: true
Display_Time: 15
# Settings for /mcstats
Stats:
Print: false
Board: true
Display_Time: 15
# Settings for /inspect
Inspect:
Print: false
Board: true
Display_Time: 20
# Settings for /mccooldown
Cooldown:
Print: true
Board: true
Display_Time: 41
# Settings for /<skillname> (e.g. /mining, /unarmed)
# No "print" option is given here; the information will always be displayed in chat.
# It should also be noted that this display is pretty dang cool.
Skill:
Board: true
Display_Time: 30
# Should the board be shown when a player levels up, and for how long?
# It is recommended to NOT have LevelUp_Time be -1, as this may confuse players.
LevelUp_Board: true
LevelUp_Time: 5
Mob_Healthbar:
# Enabled: Whether or not the feature is enabled at all
# Display_Type: Per player Default display for mob health bars - HEARTS, BAR, or DISABLED
# Display_Time: Amount of time (in seconds) to display. To display permanently, set to -1
Enabled: true
Display_Type: HEARTS
Display_Time: 3
Database_Purging:
# Amount of time (in hours) to wait between database purging
# To only run at server start, set to 0
# To never run, set to -1
Purge_Interval: -1
# Any user who hasn't connected in this many months will be purged from the database
# To never purge old users, set to -1
Old_User_Cutoff: 6
#
# Settings for Backups
# Allow mcMMO to create zip backups for config files and flatfile data on shutdown.
###
Backups:
Enabled: true
Keep:
Last_24_Hours: true
Daily_Last_Week: true
Weekly_Past_Months: true
#
# Settings for using a mySQL database
###
MySQL:
Enabled: false
Database:
User_Name: UserName
User_Password: UserPassword
Name: DataBaseName
TablePrefix: mcmmo_
# This setting is the max simultaneous mysql connections allowed at a time, needs to be
# high enough to support multiple player logins in quick succession
MaxConnections:
Misc: 30
Load: 30
Save: 30
# This setting is the max size of the pool of cached connections that we hold available
# at any given time
MaxPoolSize:
Misc: 10
Load: 20
Save: 20
Server:
SSL: true
Port: 3306
Address: localhost
#
# Settings for Hardcore mode
# Players will not lose stats when their level is below the Level_Threshold
###
Hardcore:
Death_Stat_Loss:
Penalty_Percentage: 75.0
Level_Threshold: 0
Enabled:
Acrobatics: false
Alchemy: false
Archery: false
Axes: false
Excavation: false
Fishing: false
Herbalism: false
Mining: false
Repair: false
Swords: false
Taming: false
Unarmed: false
Woodcutting: false
Vampirism:
Leech_Percentage: 5.0
Level_Threshold: 0
Enabled:
Acrobatics: false
Alchemy: false
Archery: false
Axes: false
Excavation: false
Fishing: false
Herbalism: false
Mining: false
Repair: false
Swords: false
Taming: false
Unarmed: false
Woodcutting: false
#
# Settings for SMP Mods
###
Mods:
Tool_Mods_Enabled: false
Armor_Mods_Enabled: false
Block_Mods_Enabled: false
Entity_Mods_Enabled: false
#
# Settings for mcMMO items
###
Items:
Chimaera_Wing:
Enabled: true
Cooldown: 240
Warmup: 5
RecentlyHurt_Cooldown: 60
Prevent_Use_Underground: true
# Attempt to use the bed spawn, if one is available
Use_Bed_Spawn: true
Use_Cost: 1
Recipe_Cost: 5
Item_Name: FEATHER
Sound_Enabled: true
Flux_Pickaxe:
Sound_Enabled: true
#
# Settings for Parties
###
Party:
# Enable Hurting other players in the same party
FriendlyFire: false
# Maximum size for a party, -1 for infinite
MaxSize: -1
# Amount of time (in hours) to wait between automatically kicking old party members
# To only run at server start, set to 0
# To never kick old users, set to -1
AutoKick_Interval: 12
# Any user who hasn't connected in this many days will get kicked from their party
Old_Party_Member_Cutoff: 7
# Settings for party share modes
Sharing:
ExpShare_bonus_base: 1.1
ExpShare_bonus_increase: 1.05
ExpShare_bonus_cap: 1.5
Range: 75.0
# Party members level up their party by earning individual experience
# Newly created parties will not immediately have access to all the party features
# and have to level up the party a bit before they can use them.
Leveling:
Level_Cap: 10
# Uses the regular XP formula but is multiplied by <amount of party members> + <Xp_Curve_Modifier>
Xp_Curve_Modifier: 3
Near_Members_Needed: false
Inform_All_Party_Members_On_LevelUp: false
Chat_UnlockLevel: 1
Teleport_UnlockLevel: 2
Alliance_UnlockLevel: 5
ItemShare_UnlockLevel: 8
XpShare_UnlockLevel: 10
#
# Settings for Abilities
###
Abilities:
Enabled: true
Messages: true
Activation:
Only_Activate_When_Sneaking: false
Cooldowns:
Berserk: 240
Blast_Mining: 60
Giga_Drill_Breaker: 240
Green_Terra: 240
Serrated_Strikes: 240
Skull_Splitter: 240
Super_Breaker: 240
Tree_Feller: 240
Max_Seconds:
Berserk: 0
Blast_Mining: 0
Giga_Drill_Breaker: 0
Green_Terra: 0
Serrated_Strikes: 0
Skull_Splitter: 0
Super_Breaker: 0
Tree_Feller: 0
Limits:
Tree_Feller_Threshold: 500
Tools:
# Use more tool durability while using abilities. Set Durability_Loss to 0 to disable the extra durability damage.
Durability_Loss: 1
#
# Settings for Skills
# Level cap of 0 for no limit
###
Skills:
Acrobatics:
Enabled_For_PVP: true
Enabled_For_PVE: true
Prevent_AFK_Leveling: true
Max_Tries_At_Same_Location: 3
Prevent_Dodge_Lightning: false
# Prevent earning Acrobatics XP a few seconds after teleporting
XP_After_Teleport_Cooldown: 5
Level_Cap: 0
Alchemy:
# Allow Hoppers to transfer ingredients and brew Rank 1 Alchemy potions
Enabled_for_Hoppers: true
# Prevent Hoppers from transferring ingredients into Brewing Stands
Prevent_Hopper_Transfer_Ingredients: false
# Prevent Hoppers from transferring bottles into Brewing Stands
Prevent_Hopper_Transfer_Bottles: false
Level_Cap: 0
Archery:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0
Axes:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0
Ability_Activation_Level_Gate: 10
Excavation:
Level_Cap: 0
Ability_Activation_Level_Gate: 10
Fishing:
Level_Cap: 0
Drops_Enabled: true
Override_Vanilla_Treasures: true
# Always catch fish, even when treasure is found
Extra_Fish: false
Lure_Modifier: 4.0
Herbalism:
Level_Cap: 0
Prevent_AFK_Leveling: true
Mining:
Level_Cap: 0
Detonator_Name: FLINT_AND_STEEL
Ability_Activation_Level_Gate: 10
Repair:
Level_Cap: 0
Anvil_Messages: true
Anvil_Placed_Sounds: true
Anvil_Use_Sounds: true
Anvil_Material: IRON_BLOCK
# Ask for a confirmation when a player tries to repair an enchanted item
Confirm_Required: true
Salvage:
Level_Cap: 0
Anvil_Messages: true
Anvil_Placed_Sounds: true
Anvil_Use_Sounds: true
Anvil_Material: GOLD_BLOCK
# Ask for a confirmation when a player tries to salvage an enchanted item
Confirm_Required: true
Smelting:
Level_Cap: 0
Swords:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0
Ability_Activation_Level_Gate: 10
Taming:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0
Call_Of_The_Wild:
# Item_Material: Material of the item needed to summon the pet
# Item_Amount: Amount of items required to summon the pet
# Summon_Amount: Amount of pets to summon when using Call Of The Wild
# Summon_Length: Pets despawn when their summon life length expires
# Summon_Max_Amount: Maximum amount of pets that can be summoned at the same time
Wolf:
Item_Material: BONE
Item_Amount: 10
Summon_Amount: 1
Summon_Length: 240
Summon_Max_Amount: 10
Ocelot:
Item_Material: COD
Item_Amount: 10
Summon_Amount: 1
Summon_Length: 240
Summon_Max_Amount: 10
Horse:
Item_Material: APPLE
Item_Amount: 10
Summon_Amount: 1
Summon_Length: 240
Summon_Max_Amount: 10
# Range to check for nearby pets when using Call Of The Wild, 0 will disable the check
Range: 40.0
Unarmed:
Enabled_For_PVP: true
Enabled_For_PVE: true
Level_Cap: 0
Ability_Activation_Level_Gate: 10
Block_Cracker:
SmoothBrick_To_CrackedBrick: true
# When using Unarmed, picked up items will automatically get moved to a free slot instead of going in the slot
# of your hand. Should item pickup be disabled when your entire inventory - except for your hand - is full?
Item_Pickup_Disabled_Full_Inventory: true
# Any attacks made without a tool, i.e. with one's open hand, a block, etc., will count as unarmed.
Items_As_Unarmed: false
Woodcutting:
Tree_Feller_Sounds: true
Level_Cap: 0
Ability_Activation_Level_Gate: 10
#
# Settings for Double Drops
###
Double_Drops:
Herbalism:
Beetroots_Ripe: true
Brown_Mushroom: true
Cactus: true
Carrots_Ripe: true
Cocoa_Ripe: true
Wheat_Ripe: true
Melon: true
Nether_Wart_Ripe: true
Potatoes_Ripe: true
Pumpkin: true
Red_Mushroom: true
Red_Tulip: true
Sugar_Cane: true
Vine: true
Lily_Pad: true
Dandelion: true
Mining:
Coal_Ore: true
Diamond_Ore: true
Emerald_Ore: true
End_Stone: true
Glowstone: true
Gold_Ore: true
Iron_Ore: true
Lapis_Ore: true
Mossy_Cobblestone: true
Netherrack: true
Obsidian: true
Nether_Quartz_Ore: true
Redstone_Ore: true
Sandstone: true
Stone: true
Woodcutting:
Acacia_Log: true
Birch_Log: true
Dark_Oak_Log: true
Oak_Log: true
Jungle_Log: true
Spruce_Log: true
#
# Settings for commands
###
Commands:
Skills:
# Turn this off to prevent mcMMO URL links from being sent
URL_Links: true
Generic:
# If true, when using partial names in commands mcMMO will try to look for a match from
# the offline players. Enabling this might slow the server down if there are a lot of offline players.
Match_OfflinePlayers: false
Database:
# Database command cooldown in milliseconds, cannot be changed below the default value. (1750)
# Prevents players from spamming /mctop or /mcrank
Player_Cooldown: 1750
mcmmo:
Donate_Message: true
inspect:
Max_Distance: 30.0
ptp:
Cooldown: 120
Warmup: 5
RecentlyHurt_Cooldown: 60
Accept_Required: true
Request_Timeout: 300
# If true, require players to have a mcmmo.commands.ptp.world.[WorldName] permission
# to teleport to, from, or within any given world.
World_Based_Permissions: false
partychat:
Chat_Prefix_Format: '[[GREEN]]([[WHITE]]{0}[[GREEN]])'
Use_Display_Names: true
Chat_Prefix_Format_Ally: '[[GREEN]](A)[[RESET]]'
adminchat:
Chat_Prefix_Format: '[[AQUA]][[[WHITE]]{0}[[AQUA]]]'
Use_Display_Names: true
#
# Settings for particles
###
Particles:
# These settings determine if fireworks should get launched when a player activates/deactivates an ability
Ability_Activation: false
Ability_Deactivation: false
# Determines if the fireworks should be a large ball or a small one
LargeFireworks: true
# Use particle effect when these abilities trigger
Bleed: true
Dodge: true
Flux: true
Greater_Impact: true
Call_of_the_Wild: true
# These settings determine if fireworks should get launched when a player levels-up,
# this will happen by default for every 100 levels.
LevelUp_Enabled: true
LevelUp_Tier: 100
#
# Settings for sounds
###
Sounds:
# This setting controls the master volume. 1.0 is Max, 0 would be off
MasterVolume: 1.0

View File

@@ -1,9 +0,0 @@
#
# This file includes a few settings for each skill in mcMMO
#Acrobatics
Acrobatics:
# turn this to false to disable all subskills for this skill
Enabled: true
Roll:
Enabled: true

View File

@@ -1,440 +0,0 @@
#
# Experience configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
# Configure the experience formula and experience settings here.
#
#####
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/boss/BarColor.html
# These are the only valid colors for Experience Bars, use the exact name found here
# BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW (As of the time of this update these are the only Bar colors available, this could change in the future so check the BarColor enum to see if it has)
# BarStyle Settings (USE THE EXACT NAME) :
#SEGMENTED_10
# Splits the boss bar into 10 segments
#SEGMENTED_12
# Splits the boss bar into 12 segments
#SEGMENTED_20
# Splits the boss bar into 20 segments
#SEGMENTED_6
# Splits the boss bar into 6 segments
#SOLID
# The bar is one solid piece
ExploitFix:
EndermanEndermiteFarms: true
Experience_Bars:
# Turn this to false if you wanna disable XP bars
Enable: true
Update:
# XP that you gained from your party but not yourself
Party: true
# Passive is stuff like smelting, brewing
Passive: true
# If you want to use a fancy edited title from the locale, then you'll probably want to turn this on, but it will make your server do a lot more work!
# I recommend leaving this off!
ThisMayCauseLag:
AlwaysUpdateTitlesWhenXPIsGained:
Enable: false
# You can make your own custom details in the locale file without having to use the ExtraDetails setting!
ExtraDetails: false
Acrobatics:
Enable: true
Color: PINK
BarStyle: SEGMENTED_6
Alchemy:
Enable: true
Color: PURPLE
BarStyle: SEGMENTED_6
Archery:
Enable: true
Color: BLUE
BarStyle: SEGMENTED_6
Axes:
Enable: true
Color: BLUE
BarStyle: SEGMENTED_6
Excavation:
Enable: true
Color: YELLOW
BarStyle: SEGMENTED_6
Fishing:
Enable: true
Color: PURPLE
BarStyle: SEGMENTED_6
Herbalism:
Enable: true
Color: GREEN
BarStyle: SEGMENTED_6
Mining:
Enable: true
Color: YELLOW
BarStyle: SEGMENTED_6
Repair:
Enable: true
Color: PURPLE
BarStyle: SEGMENTED_6
Salvage:
Enable: true
Color: PURPLE
BarStyle: SEGMENTED_6
Smelting:
Enable: true
Color: PURPLE
BarStyle: SEGMENTED_6
Swords:
Enable: true
Color: BLUE
BarStyle: SEGMENTED_6
Taming:
Enable: true
Color: RED
BarStyle: SEGMENTED_6
Unarmed:
Enable: true
Color: BLUE
BarStyle: SEGMENTED_6
Woodcutting:
Enable: true
Color: GREEN
BarStyle: SEGMENTED_6
#
# Settings for XP formula
###
Experience_Formula:
# Valid values are: LINEAR and EXPONENTIAL
# If an invalid value is entered, this will reset to the default setting, which is LINEAR
# LINEAR: base + (level * multiplier)
# EXPONENTIAL: multiplier * level ^ exponent + base
Curve: LINEAR
# If invalid values are entered mcMMO will not start and print an error in the console
Linear_Values:
base: 1020
multiplier: 20
Exponential_Values:
multiplier: 0.1
exponent: 1.80
base: 2000
# Cumulative experience curves will use a players power level instead of their skill level,
# players with high power levels will have to gain a lot more experience to reach the next level in every skill.
Cumulative_Curve: false
# Experience gained in every skill will get multiplied by this value. 1.0 by default, 2.0 means two times as much
Multiplier:
Global: 1.0
PVP: 1.0
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
Mobspawners:
Multiplier: 0
Breeding:
Multiplier: 1.0
# Experience gained will get divided by these values. 1.0 by default, 2.0 means two times less XP gained.
Modifier:
Swords: 1.0
Taming: 1.0
Acrobatics: 1.0
Excavation: 1.0
Herbalism: 1.0
Unarmed: 1.0
Woodcutting: 1.0
Mining: 1.0
Archery: 1.0
Axes: 1.0
Repair: 1.0
Fishing: 1.0
Alchemy: 1.0
# XP earned by players with the permission mcmmo.perks.xp.customboost.<skillname> will get multiplied
# with 1.25 by default, resulting in a 25% XP boost
Custom_XP_Perk:
Boost: 1.25
#
# Settings for Diminished Returns
###
Diminished_Returns:
#This is the minimum amount of XP a player will earn after reaching the timed threshold (this is to prevent punishing a player too hard for earning XP)
## A value of 1 would mean that a player gets FULL XP, which defeats the purpose of diminished returns, the default value is 0.05 (5% minimum XP)
### Set this value to 0 to turn it off
Guaranteed_Minimum_Percentage: 0.05
Enabled: false
# Limit the amount of experience a player can earn:
# Threshold (amount of experience) per Time_Interval (in minutes)
Threshold:
Swords: 20000
Taming: 20000
Acrobatics: 20000
Excavation: 20000
Herbalism: 20000
Unarmed: 20000
Woodcutting: 20000
Mining: 20000
Archery: 20000
Axes: 20000
Repair: 20000
Fishing: 20000
Alchemy: 20000
Time_Interval: 10
#
# Settings for XP conversion with '/mcconvert experience'
###
Conversion:
# Old experience will get divided by this modifier
Exp_Modifier: 1
#
# Settings for XP distribution
###
Experience:
PVP:
Rewards: true
Acrobatics:
Dodge: 120
Roll: 80
Fall: 120
# FeatherFall_Multiplier: Multiply Acrobatics XP by this value when wearing boots with the Feather Fall enchant
FeatherFall_Multiplier: 2.0
Alchemy:
# Alchemy potion stages are based on the number of ingredients added
# Potion_Stage_1 represents a base potion
# Potion_Stage_2 represents a base potion with one ingredient
# Potion_Stage_3 represents a base potion with one ingredient and one amplifier
# Potion_Stage_4 represents a base potion with one ingredient and two amplifiers
# Potion_Stage_5 represents a base potion with one ingredient where the amplifiers are swapped
Potion_Stage_1: 15
Potion_Stage_2: 30
Potion_Stage_3: 60
Potion_Stage_4: 120
Potion_Stage_5: 0
Archery:
Distance_Multiplier: 0.025
Fishing:
Cod: 100
Salmon: 600
Tropical_Fish: 10000
Pufferfish: 2400
Shake: 50
Excavation:
Clay: 40
Dirt: 40
Coarse_Dirt: 40
Podzol: 40
Grass_Block: 40
Gravel: 40
Mycelium: 40
Sand: 40
Red_Sand: 40
Snow: 20
Snow_Block: 40
Soul_Sand: 40
Woodcutting:
Oak_Log: 70
Spruce_Log: 80
Birch_Log: 90
Jungle_Log: 100
Acacia_Log: 90
Dark_Oak_Log: 90
Stripped_Oak_Log: 70
Stripped_Spruce_Log: 80
Stripped_Birch_Log: 90
Stripped_Jungle_Log: 100
Stripped_Acacia_Log: 90
Stripped_Dark_Oak_Log: 90
Oak_Wood: 70
Spruce_Wood: 70
Birch_Wood: 70
Jungle_Wood: 70
Acacia_Wood: 70
Dark_Oak_Wood: 70
Mycelium: 70
Red_Mushroom_Block: 70
Brown_Mushroom_Block: 70
Mushroom_Stem: 80
Herbalism:
Tube_Coral_Fan: 80
Brain_Coral: 90
Bubble_Coral: 75
Fire_Coral: 120
Horn_Coral: 175
Dead_Tube_Coral: 30
Dead_Brain_Coral: 30
Dead_Bubble_Coral: 30
Dead_Fire_Coral: 30
Dead_Horn_Coral: 30
Allium: 300
Azure_Bluet: 150
Beetroots_Ripe: 50
Blue_Orchid: 150
Brown_Mushroom: 150
Cactus: 30
Carrots_Ripe: 50
Chorus_Flower_Ripe: 25
Chorus_Plant: 1
Cocoa_Ripe: 30
Wheat_Ripe: 50
Dead_Bush: 30
Lilac: 50
Melon: 20
Nether_Wart_Ripe: 50
Orange_Tulip: 150
Oxeye_Daisy: 150
Peony: 50
Pink_Tulip: 150
Poppy: 100
Potatoes_Ripe: 50
Pumpkin: 20
Red_Mushroom: 150
Red_Tulip: 150
Rose_Bush: 50
Fern: 10
Grass: 10
Sugar_Cane: 30
Sunflower: 50
Tall_Grass: 50
Large_Fern: 50
Vine: 10
Lily_Pad: 100
White_Tulip: 150
Dandelion: 100
Mining:
Tube_Coral_Block: 75
Brain_Coral_Block: 80
Bubble_Coral_Block: 70
Fire_Coral_Block: 90
Horn_Coral_Block: 125
Coal_Ore: 100
Diamond_Ore: 750
Emerald_Ore: 1000
End_Bricks: 200
Nether_Brick: 50
End_Stone: 30
Glowstone: 30
Gold_Ore: 350
Terracotta: 30
Iron_Ore: 250
Lapis_Ore: 400
Mossy_Cobblestone: 30
Netherrack: 30
Obsidian: 150
Packed_Ice: 50
Blue_Ice: 100
Nether_Quartz_Ore: 100
Redstone_Ore: 150
Sandstone: 30
Black_Terracotta: 50
Blue_Terracotta: 50
Brown_Terracotta: 50
Cyan_Terracotta: 50
Gray_Terracotta: 50
Green_Terracotta: 50
Light_Blue_Terracotta: 50
Light_Gray_Terracotta: 50
Lime_Terracotta: 50
Magenta_Terracotta: 50
Orange_Terracotta: 50
Pink_Terracotta: 50
Purple_Terracotta: 50
Red_Terracotta: 50
White_Terracotta: 50
Yellow_Terracotta: 50
Stone: 30
Granite: 30
Andesite: 30
Diorite: 30
Red_Sandstone: 100
Prismarine: 70
Purpur_Block: 200
Purpur_Pillar: 250
Purpur_Slab: 150
Purpur_Stairs: 250
Repair:
Base: 1000.0
Wood: 0.6
Stone: 1.3
Iron: 2.5
Gold: 0.3
Diamond: 5.0
Leather: 1.6
String: 1.8
Other: 1.5
Smelting:
Coal_Ore: 10
Diamond_Ore: 75
Emerald_Ore: 100
Gold_Ore: 35
Iron_Ore: 25
Lapis_Ore: 40
Nether_Quartz_Ore: 25
Redstone_Ore: 15
Taming:
Animal_Taming:
Wolf: 250
Ocelot: 500
Horse: 1000
Donkey: 1000
Mule: 1000
Skeleton_Horse: 1000
Zombie_Horse: 1000
Combat:
Multiplier:
Animals: 1.0
Creeper: 4.0
Skeleton: 3.0
Spider: 2.0
Giant: 4.0
Zombie: 2.0
Slime: 2.0
Ghast: 3.0
Pig_Zombie: 3.0
Enderman: 1.0
Cave_Spider: 3.0
Silverfish: 3.0
Blaze: 3.0
Magma_Cube: 2.0
Ender_Dragon: 1.0
Wither: 1.0
Witch: 0.1
Iron_Golem: 2.0
Wither_Skeleton: 4.0
Endermite: 2.0
Guardian: 3.0
Elder_Guardian: 4.0
Shulker: 2.0
Donkey: 1.0
Mule: 1.0
Horse: 1.0
Zombie_Villager: 2.0
Skeleton_Horse: 1.0
Zombie_Horse: 1.2
Husk: 3.0
Evoker: 3.0
Polar_Bear: 2.0
Llama: 1.0
Vindicator: 3.0
Stray: 2.0
Rabbit: 1.0
Chicken: 1.0
Bat: 1.0
Mushroom_Cow: 1.2
Cow: 1.0
Turtle: 1.1
Sheep: 1.0
Pig: 1.0
Squid: 1.0
Ocelot: 1.0
Villager: 1.0
Snowman: 0.0
Parrot: 1.0
Illusioner: 3.0
Drowned: 1.0
Dolphin: 1.3
Phantom: 4.0

View File

@@ -1,19 +0,0 @@
#
# WARNING: THIS CONFIG IS FOR ADVANCED USERS ONLY.
# You will need to reset any values in this config every time you update mcMMO
###
Options:
# true to use Chunklets metadata store system, false to disable
Chunklets: true
# Square root of the number of chunks to convert per tick.
ConversionRate: 1
# true to use enchantment buffs for Super Breaker & Giga Drill Breaker, false to use potion buffs
EnchantmentBuffs: true
# Amount of users to convert every interval
UUIDConvertAmount: 100
# Amount of users to be converted at a time before waiting MojangLimitPeriod milliseconds to begin again
# This setting is for large servers to avoid being temp banned from mojang api
MojangRateLimit: 300
# Amount of time to wait after hitting the MojangRateLimit in UUID conversion
MojangLimitPeriod: 6000

View File

@@ -1,96 +0,0 @@
#
# ItemStack Weights configuration
#
# This file is used to determine the value of an item. This will only
# happen when users are sharing items in a party using the EQUAL item share mode.
#
# Rare items should have a higher value than common items. If an item is not listed
# here, the value from "Default" will be used instead.
#
#####
Item_Weights:
Default: 5
Quartz: 200
Nether_Quartz_Ore: 200
Emerald: 150
Emerald_Ore: 150
Diamond: 100
Diamond_Ore: 100
Gold_Ingot: 50
Gold_Ore: 50
Iron_Ingot: 40
Iron_Ore: 40
Lapis_Ore: 30
Redstone: 30
Redstone_Ore: 30
Glowstone_Dust: 20
Coal: 10
Coal_Ore: 10
# ItemStack weights for armor and tools
Diamond_Sword: 150
Diamond_Shovel: 150
Diamond_Pickaxe: 150
Diamond_Axe: 150
Diamond_Helmet: 150
Diamond_Chestplate: 150
Diamond_Leggings: 150
Diamond_Boots: 150
Golden_Sword: 75
Golden_Shovel: 75
Golden_Pickaxe: 75
Golden_Axe: 75
Golden_Helmet: 75
Golden_Chestplate: 75
Golden_Leggings: 75
Golden_Boots: 75
Iron_Sword: 60
Iron_Shovel: 60
Iron_Pickaxe: 60
Iron_Axe: 60
Iron_Helmet: 60
Iron_Chestplate: 60
Iron_Leggings: 60
Iron_Boots: 60
# Items in this section will get added to the Misc share category.
# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum.
Party_Shareables:
Misc_Items:
- Diamond_Sword
- Diamond_Shovel
- Diamond_Pickaxe
- Diamond_Axe
- Golden_Sword
- Golden_Shovel
- Golden_Pickaxe
- Golden_Axe
- Iron_Sword
- Iron_Shovel
- Iron_Pickaxe
- Iron_Axe
- Stone_Sword
- Stone_Shovel
- Stone_Pickaxe
- Stone_Axe
- Wooden_Sword
- Wooden_Shovel
- Wooden_Pickaxe
- Wooden_Axe
- Bow
- Diamond_Helmet
- Diamond_Chestplate
- Diamond_Leggings
- Diamond_Boots
- Golden_Helmet
- Golden_Chestplate
- Golden_Leggings
- Golden_Boots
- Iron_Helmet
- Iron_Chestplate
- Iron_Leggings
- Iron_Boots
- Leather_Helmet
- Leather_Chestplate
- Leather_Leggings
- Leather_Boots

Some files were not shown because too many files have changed in this diff Show More