# Migration Guide
This section will guide you how to migrate the plugin from the old version of Blessing Skin to the new Blessing Skin.
# Migrating from 4.3.x or 4.4.0 to 5.0.0
# new version update
The PHP version requirement has been raised to 7.2.5, while Laravel has been upgraded to 7.x.
In addition, AdminLTE was upgraded to v3, and the Bootstrap used in the bottom layer of AdminLTE was also upgraded to v4.
# Usermodel
The following instance methods in this model have been removed:
setScore(please manually update the user's score and call thesavemethod)getStorageUsedsigngetSignRemainingTimecanSign
The original static method getEncryptedPwdFromEventis now changed to
an instance method, and the method signature is changed to only one
parameter, namely $raw.
# Playermodel
player_name attributethat was deprecated in BS v4 has now been
removed.
getJsonProfile, generateJsonProfile, getTexture,
isBanned on ``Playermodel instances have been removed.
# class import
The following usages have been removed. It stands to reason that the impact should be small, because the documentation never mentions such usage.
use A rr ;
use S tr ;
Change to the following usage:
use I illuminate\ S support \ A rr ;
use I illuminate\ S support \ S tr ;
# bootstrap.php
get the current plugin instance via the $plugin parameterdirectly in
the closure defined by bootstrap.php :
return function ( $plugin ) {
// $plugin is the instance of this plugin.
// You can get the front-end resource URL like this:
$plugin- >assets( 'something.css' ) ;
} ;
Additionally, Blessing Skin will now catch exceptions that occur in
bootstrap.php(not including exceptions that occur within routes
defined in it or listened to events). If an exception occurs while
executing the code in
bootstrap.php , Blessing Skin will issue a notification when the administrator visits the site.
If you don't want the exception to be caught, you can execute the code in the "service provider", and the exception that occurs in the service provider will not be caught.
# hook
Now the first parameter
$users of the ``Hook::sendNotification function canaccept a single
user and is no longer limited to an array.
Due to an update in Laravel 5.4, addScriptFileToPageand
addStyleFileToPageno longer support specifying priority (ie the third
parameter).
registerPluginTransScriptshas now been removed, because v5 uses a new
and more convenient method of loading language files, and this function
is no longer needed.
# middleware
playermiddleware has been removed;adminandsuper-adminmiddleware have been removed and replaced by therolemiddleware, which accepts a parameter, see the routing section of this document for details.
# statement conflict
This is a new feature, see here for details .
# auto load service provider
This is a new feature, see here for details .
# Responsemacro
the pngmacro and the jsonProfile macro on ``Responsehave been
removed.
# helper function
The following helper functions have been removed:
format_http_datealternative: call thetoRfc7231Stringmethod on theCarboninstancenl2palternatives: noneget_client_ipalternative: consider this library: Vectorface/whip (opens new window)get_string_replacedalternatives: None
# App\Services\Minecraftclass
This class has been removed due to the new material preview library in Blessing Skin v5. Although we don't mention this class in the documentation, if you use it, please be aware of the migration.
Currently we use the new preview library: blessing/texture-renderer (opens new window) .
# configuration page
page can now be specified via the configfield under the enchants
field in ``package.json . Ithas higher priority than the root
config .For details, please read the relevant introduction in the
definition of plug-in information .
# blessingglobal variables
notify.showModalis used completely differently than before. For
details, please refer to
here (opens new window)
.
The fallback_localeproperty has been removed.
# event
GetPlayerJsonevent has been removedGetAvatarPreviewevent has been removedGetSkinPreviewevent has been removedCheckPlayerExistsevent has been removedEncryptUserPasswordevent has been removed, please use filteruser_passwordHashingFileevent has been removed, please use filterfile_hash- The frontend
skinViewerMountedevent has been removed mounted eventon the front end no longer passes any parameters
# form
A new instance method addAlert has been added to ``OptionForm. Its
usage is similar to addMessage.
# other
Parsedown has been removed from the service container. In other words,
app('parsedown') isno longer available, and you need to manually
construct the Parsedownclass.
# Migrating from 4.2.0 to 4.3.0
# hook
addMenuItemfunction now supports the new typeexplore, which is located in the "Explore" menu under the "User Center". In addition, this function can also specifynew-tabastruein the third parameter to indicate that the link is opened in a new tab page of the browser.Added new
addUserBadge(opens new window)method.Add new
sendNotification(opens new window)method.Add a new
pushMiddleware(opens new window)method.
# Migrating from 4.1.0 to 4.2.0
# events (backend)
- A new event
TextureDeleting has been added.
# Migrating from 4.0.0 to 4.1.0
# jsonhelper function (impact: high)
helper function jsonhas changed. There are three ways to use json,
namely passing in one parameter, two parameters and three parameters.
Currently, the behavior when one parameter is passed in is unchanged.
Before, if two parameters were passed in, the returned response would be like this:
{
"errno" : 0 ,
"msg" : ""
}
has now been changed to:
{
"code" : 0 ,
"message" : ""
}
The fields have the same meaning. So please change the front-end code as needed.
Before, if three parameters were passed in, such as:
json( 'text' , 0 , [ 'abc' => 123 ]) ;
The response returned will be like this:
{
"errno" : 0 ,
"msg" : "text" ,
"abc" : 123
}
In 4.1.0 it will be:
{
"code" : 0 ,
"message" : "text" ,
"data" : {
"abc" : 123
}
}
Please change the front-end code as needed.
# events (backend)
- A new event
PlayerRetrieved has been added.
# Events (Frontend)
- A new event
i18nLoaded has been added.
# Migrated from 3.5.0 to 4.0.0
# Bottom Upgrading (Influence: High)
In Blessing Skin v4, the version of Laravel framework has been upgraded to 5.8, and PHP requires 7.1.8 or higher. Please make sure your plugin code is compatible with PHP 7.1.8+ and Laravel 5.8.
# User Authentication (Influence: High)
Blessing Skin v4 refactors the user authentication system and uses Laravel's own authentication function. See the section on user authentication for details . Here is a simple demonstration of basic usage:
auth()->id() ; // Get the UID of the current user
auth()->user() ; // Get the model instance
auth()->check() of the current user ; // Check if the user is logged in, but you should consider using the `auth` middleware for this
# Front-end browser compatibility (influence: low)
IE is no longer supported, so you can safely use ES 2015 features, but
for ES 2016 and newer features (such as the more common
async/awaitfunctions in ES 2017), it is still recommended to use
Babel for transcoding.
# Font Awesome (Influence: Medium)
Font Awesome has been upgraded to v5, please read the documentation of Font Awesome for specific changes.
# Utilsclass (impact: high)
App\Services\Utilsclass has been completely removed and replaced by
helper functions .
The following are the corresponding names of some methods of the
original Utilsclass in the auxiliary function:
Utilsclass | function name in helper function |
|---|---|
| getClientIp | get_client_ip |
| isRequestSecure | is_request_secure |
| getTimeFormatted | get_datetime_string |
| getStringReplaced | get_string_replaced |
# View Files (Influence: Medium)
.tpl isno longer supported , please use .blade.php.
# Front-end functions (influence: high)
Since 4.0.0 uses webpack for frontend builds, most of the global JavaScript functions that were in 3.5.0 are no longer available.
# transfunction
transfunction is used for front-end multilingual, it is still
available.
# jQuery
jQuery is available globally.
# showModaland showMsgfunctions
showModalhas been moved into the blessing.notifyobject, the
functionality remains the same.
showMsghas been removed.
swaland toastrhave been removed. Although available in v3, we
never considered this a feature.
# fetchfunction
Starting from 4.0.0, Blessing Skin uses the browser's native Fetch API,
that is, the browser's native fetchfunction, while the
fetch in 3.5.0is covered by Blessing Skin with $.ajax, which is
not a real Fetch API.
If you're using this fake fetch in your plugin, see Frontend Network
Requests for how to migrate it. In addition,
if your plugin has manually overridden the fetchfunction, please
modify this part of the code! (Otherwise it will affect the work of
Blessing Skin itself)
# showAjaxErrorfunction
This function is only used internally by Blessing Skin and is no longer exposed because you no longer need to catch these errors manually by yourself.
# DOM modification (impact: high)
4.0.0 uses Vue.js to render pages on many pages. If your plugin needs to
modify the DOM, then you should use blessing.event.onto listen to the
mountedevent, and modify the DOM after the event is triggered. But it
should be noted that please do not modify the DOM elements managed and
controlled by Vue.js (but can be read), otherwise it may affect the
operation of Blessing Skin.
Pages that do not use Vue.js are not affected, and the mountedevent
will not be fired.
Please read here about the
mounted event.
# Front-end multilingual (influence: medium)
All multilingual texts are now stored under blessing.i18n. For
multilingual plug-ins, you only need to create an attribute under the
blessing.i18nobject, and you don't need to specify the language .
like this:
blessing.i18n.configGenerator _ _ _ _ = {
key1 : 'text1'
}
To use, just call the globally available transfunction as before:
trans ( 'configGenerator.key1.text1' )
# Usermodel (influence: medium)
changePasswd method on the ``Usermodel instance has been renamed to
changePassword, the functionality remains the same.
The static method register on the ``User modelhas been removed.
getToken method on the ``Usermodel instance has been removed as the
authentication system has been refactored and this method no longer
makes sense.
setEmail method on ``Usermodel instances has been removed.
getNickName method on ``Usermodel instances has been removed.
setNickName method on ``Usermodel instances has been removed.
getScore method on ``Usermodel instances has been removed.
getAvatarId method on ``Usermodel instances has been removed.
setAvatar method on ``Usermodel instances has been removed.
getLastSignTime method on ``Usermodel instances has been removed.
getPermission method on ``Usermodel instances has been removed.
setPermission method on ``Usermodel instances has been removed.
# PlayerModel (Influence: High)
Starting from 4.0.0, the character no longer has the concept of "model", that is, what kind of model is the material set by the character, and the JSON API will automatically set the model correctly.
Therefore, the preference, tid_steve ,and
tid_alex fields on the ``Playermodel have all been removed, and
instead, please use the new tid_skinfield.
Also, the player_namefield has been renamed to name.
rename method on ``Playermodel instances has been removed.
setOwner method on ``Playermodel instances has been removed.
clearTexture method on ``Playermodel instances has been removed.
setTexture method on ``Playermodel instances has been removed.
checkForInvalidTextures method on ``Playermodel instances has been
removed.
# Texturemodel (influence: medium)
setPrivacy on the ``Texturemodel instance has been removed, please
directly update the value of $texture->publicand $texture->save().
likesfield is now read-only.
# Closetmodel (influence: high)
Closetmodel has been removed, please do not use
App\Models\Closet anymore.
If you need to access a certain user's wardrobe, you can call it like this:
$user- >closet()->get() ;
Like the result above, you can get all the items in the closet and
return a Laravel Collection, where each element is a Texturemodel
instance.
Also, if you need to get the name of the item (not the name of the material in the skin library), you can:
$ texture->pivot->item_name ;
Blessing Skin uses Laravel's model many-to-many association to realize the wardrobe function. For more information, please read the Laravel documentation (opens new window) .
# Middleware (impact: low)
adminmiddleware will not run the CheckAuthenticatedmiddleware
first and then do the permission check, that is, the adminmiddleware
directly obtains Auth::user(). This is safe and will not report an
error because the user is not logged in, provided that you must use the
authmiddleware.
# Auxiliary functions (influence: medium)
- helper function
get_db_typehas been renamed tohumanize_db_type, the functionality remains the same. - helper function
runtime_checkhas been removed, normally this does not affect plugins as plugins should not use this function. - helper function
die_with_utf8_encodinghas been removed, it is recommended to usethrow new PrettyPageExceptionto get a more friendly error reporting interface. - Helper function
bs_announcementhas been removed, use:app('parsedown')->text(option_localized('announcement')); if needed. - helper function
can_moderate_texturehas been removed. - helper function
menv has been removed, please use the global helper function ``envprovided by Laravel . - helper function
assetshas been removed, normally this does not affect plugins as plugins should not use this function. - helper function
get_current_urlhas been removed.
# Composer dependency (impact: low)
Removed Datatablesextension package (ie
printempw/laravel-datatables-lite). If your plugin depends on this
extension pack, please manually install this dependency in your plugin,
Blessing Skin will load it.
# Event (Impact: Low)
# Change
rawPasswd property in the ``EncryptUserPasswordevent has now been
renamed rawand the type remains the same.
# Form Validation Rules (Impact: Low)
The form validation rules that were deprecated in 3.5.0 have now been removed, they are:
playernamenicknamepname_chinese
# Migrating from 3.4.0 to 3.5.0
# Composer
Blessing Skin now supports plugins to use Composer to install
dependencies, you only need to package the vendordirectory with the
plugin when publishing the plugin.
# Identify the version of Blessing Skin
You need to add a require field in ``package.jsonto specify the
plugin's dependencies. It is recommended that you specify the Blessing
Skin version supported by the plugin in this field (see here for
details ). If you do not
specify the version of Blessing Skin, users will receive an "ambiguous
dependency" warning when enabling your plugin. Although this does not
affect the operation of the plugin, it is not user-friendly.
# Utilsclass obsolete
App\Services\Utilsclass is deprecated and will be completely removed
in the next release. In 3.5.0, some methods in the Utilsclass have
been removed, and the remaining available methods can be found in the
app/Services/Utils.php
file (opens new window)
.