# 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.
# User
model
The following instance methods in this model have been removed:
setScore
(please manually update the user's score and call thesave
method)getStorageUsed
sign
getSignRemainingTime
canSign
The original static method getEncryptedPwdFromEvent
is now changed to
an instance method, and the method signature is changed to only one
parameter, namely $raw
.
# Player
model
player_name attribute
that was deprecated in BS v4 has now been
removed.
getJsonProfile
, generateJsonProfile
, getTexture
,
isBanned on ``Player
model 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 parameter
directly 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 can
accept a single
user and is no longer limited to an array.
Due to an update in Laravel 5.4, addScriptFileToPage
and
addStyleFileToPage
no longer support specifying priority (ie the third
parameter).
registerPluginTransScripts
has now been removed, because v5 uses a new
and more convenient method of loading language files, and this function
is no longer needed.
# middleware
player
middleware has been removed;admin
andsuper-admin
middleware have been removed and replaced by therole
middleware, 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 .
# Response
macro
the png
macro and the jsonProfile macro on ``Response
have been
removed.
# helper function
The following helper functions have been removed:
format_http_date
alternative: call thetoRfc7231String
method on theCarbon
instancenl2p
alternatives: noneget_client_ip
alternative: consider this library: Vectorface/whip (opens new window)get_string_replaced
alternatives: None
# App\Services\Minecraft
class
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 config
field under the enchants
field in ``package.json . It
has higher priority than the root
config .
For details, please read the relevant introduction in the
definition of plug-in information .
# blessing
global variables
notify.showModal
is used completely differently than before. For
details, please refer to
here (opens new window)
.
The fallback_locale
property has been removed.
# event
GetPlayerJson
event has been removedGetAvatarPreview
event has been removedGetSkinPreview
event has been removedCheckPlayerExists
event has been removedEncryptUserPassword
event has been removed, please use filteruser_password
HashingFile
event has been removed, please use filterfile_hash
- The frontend
skinViewerMounted
event has been removed mounted event
on 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') is
no longer available, and you need to manually
construct the Parsedown
class.
# Migrating from 4.2.0 to 4.3.0
# hook
addMenuItem
function now supports the new typeexplore
, which is located in the "Explore" menu under the "User Center". In addition, this function can also specifynew-tab
astrue
in 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
# json
helper function (impact: high)
helper function json
has 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/await
functions 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.
# Utils
class (impact: high)
App\Services\Utils
class has been completely removed and replaced by
helper functions .
The following are the corresponding names of some methods of the
original Utils
class in the auxiliary function:
Utils class | 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 is
no 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.
# trans
function
trans
function is used for front-end multilingual, it is still
available.
# jQuery
jQuery is available globally.
# showModal
and showMsg
functions
showModal
has been moved into the blessing.notify
object, the
functionality remains the same.
showMsg
has been removed.
swal
and toastr
have been removed. Although available in v3, we
never considered this a feature.
# fetch
function
Starting from 4.0.0, Blessing Skin uses the browser's native Fetch API,
that is, the browser's native fetch
function, while the
fetch in 3.5.0
is 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 fetch
function, please
modify this part of the code! (Otherwise it will affect the work of
Blessing Skin itself)
# showAjaxError
function
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.on
to listen to the
mounted
event, 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 mounted
event
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.i18n
object, and you don't need to specify the language .
like this:
blessing.i18n.configGenerator _ _ _ _ = {
key1 : 'text1'
}
To use, just call the globally available trans
function as before:
trans ( 'configGenerator.key1.text1' )
# User
model (influence: medium)
changePasswd method on the ``User
model instance has been renamed to
changePassword
, the functionality remains the same.
The static method register on the ``User model
has been removed.
getToken method on the ``User
model instance has been removed as the
authentication system has been refactored and this method no longer
makes sense.
setEmail method on ``User
model instances has been removed.
getNickName method on ``User
model instances has been removed.
setNickName method on ``User
model instances has been removed.
getScore method on ``User
model instances has been removed.
getAvatarId method on ``User
model instances has been removed.
setAvatar method on ``User
model instances has been removed.
getLastSignTime method on ``User
model instances has been removed.
getPermission method on ``User
model instances has been removed.
setPermission method on ``User
model instances has been removed.
# Player
Model (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 ``Player
model have all been removed, and
instead, please use the new tid_skin
field.
Also, the player_name
field has been renamed to name
.
rename method on ``Player
model instances has been removed.
setOwner method on ``Player
model instances has been removed.
clearTexture method on ``Player
model instances has been removed.
setTexture method on ``Player
model instances has been removed.
checkForInvalidTextures method on ``Player
model instances has been
removed.
# Texture
model (influence: medium)
setPrivacy on the ``Texture
model instance has been removed, please
directly update the value of $texture->public
and $texture->save()
.
likes
field is now read-only.
# Closet
model (influence: high)
Closet
model 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 Texture
model
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)
admin
middleware will not run the CheckAuthenticated
middleware
first and then do the permission check, that is, the admin
middleware
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
auth
middleware.
# Auxiliary functions (influence: medium)
- helper function
get_db_type
has been renamed tohumanize_db_type
, the functionality remains the same. - helper function
runtime_check
has been removed, normally this does not affect plugins as plugins should not use this function. - helper function
die_with_utf8_encoding
has been removed, it is recommended to usethrow new PrettyPageException
to get a more friendly error reporting interface. - Helper function
bs_announcement
has been removed, use:app('parsedown')->text(option_localized('announcement')); if needed
. - helper function
can_moderate_texture
has been removed. - helper function
menv has been removed, please use the global helper function ``env
provided by Laravel . - helper function
assets
has been removed, normally this does not affect plugins as plugins should not use this function. - helper function
get_current_url
has been removed.
# Composer dependency (impact: low)
Removed Datatables
extension 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 ``EncryptUserPassword
event has now been
renamed raw
and 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:
playername
nickname
pname_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 vendor
directory with the
plugin when publishing the plugin.
# Identify the version of Blessing Skin
You need to add a require field in ``package.json
to 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.
# Utils
class obsolete
App\Services\Utils
class is deprecated and will be completely removed
in the next release. In 3.5.0, some methods in the Utils
class have
been removed, and the remaining available methods can be found in the
app/Services/Utils.php
file (opens new window)
.