Giter Club home page Giter Club logo

mcrcon's Introduction

MCRcon

Straightforward implementation of Minecraft's Rcon protocol in Python.

  • mcrcon.py is a module you can import from your own python code to send commands to a minecraft server and read responses.
  • demo.py is a simple command-line client that lets you do the above without writing any code.

mcrcon's People

Contributors

barneygale avatar fenhl avatar frymaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mcrcon's Issues

Receive all outputs?

Is there a way to output all of the server messages without having to send a command?

socket.error: [Errno 111] Connection refused

Traceback (most recent call last):
File "demo.py", line 43, in
main()
File "demo.py", line 25, in main
sock.connect((args.host, args.port))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

struct.error: unpack requires a bytes object of length 4

I always get this error, password length is 20:

Traceback (most recent call last):
  File "demo.py", line 39, in <module>
    main(host, port, password)
  File "demo.py", line 16, in main
    rcon.login(password)
  File "C:\Data\username\Data\MCRcon-master\MCRcon-master\mcrcon.py", line 55, in login
    return self.send(3, password)
  File "C:\Data\username\Data\MCRcon-master\MCRcon-master\mcrcon.py", line 33, in send
    in_length, = struct.unpack('<i', self.socket.recv(4))
struct.error: unpack requires a bytes object of length 4

It occurs for python2 and for python3. Do you experience the same?

MCrcon encoding

Hi, I installed mcrcon and it connects just fine, but in the terminal I have some sort of encoding problem. My terminal is set to use UTF-8 (gnome 3/arch linux), but up-arrow gives instead of command history output you can see on the bottom line and ? gives this output with strange characters. Could you help with this please?

�--------- �Help: Index (1/23) �--------------------
�Use /help [n] to get page n of help.
�Aliases: �Lists command aliases
�Bukkit: �All commands for Bukkit
�Essentials: �All commands for Essentials
�EssentialsSpawn: �All commands for EssentialsSpawn
�Minecraft: �All commands for Minecraft
�/achievement: �A Mojang provided command.
�/afk: �Marks you as away-from-keyboard.
�/antioch: �A little surprise for operators.
> ^[[A

Commands seem to work ok, it is just strange characters that get appended

> who
ÂThere are Â3Â out of maximum Â20Â players online.

That is when I set encoding to Western ISO-8895-1

Sending commands that take long compute time crashes Minecraft server

Running the following code will crash the Minecraft server. My guess is that the Minecraft server is still parsing the result of the executed command and the "connect()" function quits too soon.

import mcrcon
server = mcrcon.MCRcon(host='x.x.x.x', port=25575, password='asdf')
server.connect()
server.command('/fill 639995 11 639995 640069 15 640069 water replace')

Possibly adding a "waittime" variable to pass with the connect() function could solve this?

License

There's no license here. I'd like to use this for a tool I'm building. Any chance you could add an MIT license or other?

Connection refused, yet other rcon tools work fine.

I can use other RCON tools to run commands/query my server, but with your demo.py, I get the following. Please let me know if there is any other information I can provide to aide in solving this issue.

[root@[omitted]]# python rcon.py 127.0.0.1 32571 [omitted]

connecting to 127.0.0.1:32571...

Traceback (most recent call last):
File "rcon.py", line 39, in
main(host, port, password)
File "rcon.py", line 13, in main
rcon.connect(host, port)
File "/root/bin/mcrcon.py", line 14, in connect
self.socket.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused
[root@[omitted]]#

Long responses are not fully returned and returned before the next command response

Some commands have a long output (e.g. "pex" from PermissionsEx) which cause MCRcon to not fully return the command output in the command() or send() methods.

Once a command with a long output is sent, the next command sent to the server returns the remaining part of the previous command and all following commands return the response of the previous one.

Example using demo.py (executing the commands "pex", "dynmap", "essentials", "", ""):

> pex
  [PermissionsEx] version [1.23.4]
Usage:
/pex - Display help
/pex reload - Reload environment
/pex report - Report an issue with PEX
/pex config <node> [value] - Print or set <node> [value]
/pex backend - Print currently used backend
/pex backend <backend> - Change permission backend on the fly (Use with caution!)
/pex hierarchy [world] - Print complete user/group hierarchy
/pex import <backend> - Import data from <backend> into currently selected backend
/pex convert uuid - Bulk convert user data to UUID-based storage
/pex toggle debug - Enable/disable debug mode
/pex help [page] [count] - PermissionsEx commands help
/pex users list - List all registered users
/pex users - List all registered users (alias)
/pex user - List all registered users (alias)
/pex user <user> - List user permissions (list alias)
/pex user <user> list [world] - List user permissions
/pex user <user> superperms - List user actual superperms
/pex user <user> prefix [newprefix] [world] - Get or set <user> prefix
/pex user <user> suffix [newsuffix] [world] - Get or set <user> suffix
/pex user <user> toggle debug - Toggle debug only for <user>
/pex user <user> check <permission> [world] - Checks player for <permission>
/pex user <user> get <option> [world] - Toggle debug only for <user>
/pex user <user> delete - Remove <user>
/pex user <user> add <permission> [world] - Add <permission> to <user> in [world]
/pex user <user> remove <permission> [world] - Remove permission from <user> in [world]
/pex user <user> swap <permission> <targetPermission> [world] - Swap <permission> and <targetPermission> in permission list. Could be number or permission itself
/pex user <user> timed add <permission> [lifetime] [world] - Add timed <permissions> to <user> for [lifetime] seconds in [world]
/pex user <user> timed remove <permission> [world] - Remove timed <permission> from <user> in [world]
/pex user <user> set <option> <value> [world] - Set <option> to <value> in [world]
/pex user <user> group list [world] - List all <user> groups
/pex user <user> group add <group> [world] [lifetime] - Add <user> to <group>
/pex user <user> group set <group> [world] - Set <group> for <user>
/pex user <user> group remove <group> [world] - Remove <user> from <group>
/pex users cleanup <group> [threshold] - Clean users of specified group, which last login was before threshold (in days). By default threshold is 30 days.
/pex group <group> swap <permission> <targetPermission> [world] - Swap <permission> and <targetPermission> in permission list. Could be number or permission itself
/pex groups list [world] - List all registered groups
/pex groups - List all registered groups (alias)
/pex group - List all registered groups (alias)
/pex group <group> weight [weight] - Print or set group weight
/pex group <group> toggle debug - Toggle debug mode for group
/pex group <group> prefix [newprefix] [world] - Get or set <group> prefix.
/pex group <group> suffix [newsuffix] [world] - Get or set <group> suffix
/pex group <group> create [parents] - Create <group> and/or set [parents]
/pex group <group> delete - Remove <group>
/pex group <group> parents [world] - List parents for <group> (alias)
/pex group <group> parents list [world] - List parents for <group>
/pex group <group> parents set <parents> [world] - Set parent(s) for <group> (single or comma-separated list)
/pex group <group> parents add <parents> [world] - Set parent(s) for <group> (single or comma-separated list)
/pex group <group> parents remove <parents> [world] - Set parent(s) for <group> (single or comma-separated list)
/pex group <group> - List all <group> permissions (alias)
/pex group <group> list [world] - List all <group> permissions in [world]
/pex group <group> add <permission> [world] - Add <permission> to <group> in [world]
/pex group <group> set <option> <value> [world] - Set <option> <value> for <group> in [world]
/pex group <group> remove <permission> [world] - Remove <permission> from <group> in [world]
/pex group <group> timed add <permission> [lifetime] [world] - Add timed <permission> to <group> with [lifetime] in
> dynmap
  [world]
/pex group <group> timed remove <permission> [world] - Remove timed <permissions> for <group> in [world]
/pex group <group> users - List all users in <group>
/pex group <group> user add <user> [world] - Add <user> (single or comma-separated list) to <group>
/pex group <group> user remove <user> [world] - Add <user> (single or comma-separated list) to <group>
/pex default group [world] - Print default groups for specified world
/pex set default group <group> <value> [world] - Set whether a group is default for specified worlds
/pex group <group> rank [rank] [ladder] - Get or set <group> [rank] [ladder]
/pex promote <user> [ladder] - Promotes <user> to next group on [ladder]
/pex demote <user> [ladder] - Demotes <user> to previous group or [ladder]
/pex worlds - Print loaded worlds
/pex world <world> - Print <world> inheritance info
/pex world <world> inherit <parentWorlds> - Set <parentWorlds> for <world>

> essentials
  /dynmap - Control execution of dynmap.
 Valid subcommands:  add-id-for-ip cancelrender del-id-for-ip fullrender hide ids-for-ip ips-for-id pause purgemap purgequeue purgeworld quiet radiusrender render resetstats sendtoweb show stats triggerstats updaterender version webregister

>
  /<command> <reload/debug>

>
  Unknown command. Type "/help" for help.

>

unpack requires a buffer of 8 bytes

I’m making a discord bot that, when given a command, will execute the command in the console, everything connects, but the error comes up: unpack requires a buffer of 8 bytes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.