ivan-1f / mcdreforged-plugins Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
1、Command function need class Literal from MCDReforged, not from python standard library typing.
This may be caused by your auto import from IDE. MCDReforged has class Literal, but typing also has it. So your IDE make it imported from typing. That's not correct. And it will be running well in Python 3.8. Because import all from MCDReforged will overlap the import from typing. But under python 3.8, it will occur errors, because class Literal is new feature of library typing. It will cause ImportError.
2、Runtime error was caused by incorrectly method call.
Your code line 37 has a severe bug.
server.register_command(Literal(PREFIX).runs(lambda src: src.reply(help_msg)).then(Text('player').runs(lambda src, ctx: src.reply(reply_info(server, src, ctx)))))
Look at the end of this line. You make method run()
to call src.reply()
, and put arguments reply_info()
in it. But see below:
def reply_info(server: ServerInterface, src: CommandSource, ctx):
api = server.get_plugin_instance('minecraft_data_api')
dim = api.get_player_dimension(ctx['player'])
cord = api.get_player_coordinate(ctx['player'])
src.reply('§6{} §7@ {} [x:{}, y:{}, z:{}]'.format(src.player, dim_convert[dim], int(cord.x), int(cord.y), int(cord.z)))
There is already a call to src.reply()
made by reply_info()
and you didn't return anything from function reply_info()
. That will make None
put to src.reply()
and raise an error.
3、After fix 2 bugs above, there was a little functional bug. When I want to see the location of player Alex
, I run command !!where Alex
. But the result of my calling shows my name not Alex
. See picture:
That's not correct.
I have commited a pull request to fix these bugs. Please review and merge it. And wish you can make some tests next time you write a plugin. : )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.