Last active
August 29, 2015 13:56
-
-
Save kamilion/9150547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base_plugin import SimpleCommandPlugin | |
from utility_functions import give_item_to_player | |
from plugins.core.player_manager import permissions, UserLevels | |
class FuelGiver(SimpleCommandPlugin): | |
""" | |
Welcomes new players by giving them fuel to leave the spawn world. | |
""" | |
name = "fuelgiver_plugin" | |
depends = ["command_dispatcher", "player_manager"] | |
commands = ["fuel"] | |
auto_activate = True | |
def activate(self): | |
super(FuelGiver, self).activate() | |
self.player_manager = self.plugins['player_manager'].player_manager | |
@permissions(UserLevels.GUEST) | |
def fuel(self, data): | |
"""Gives you some fuel items (only once). Syntax: /fuel""" | |
try: | |
my_storage = self.protocol.player.storage | |
except AttributeError: | |
self.logger.debug("Tried to give item to non-existent protocol.") | |
return | |
if not 'last_given_fuel' in my_storage or my_storage['last_given_fuel'] == "False": | |
my_storage['last_given_fuel'] = "True" | |
give_item_to_player(self.protocol, "fillerup", 1) | |
self.protocol.player.storage = my_storage | |
self.protocol.send_chat_message("^#F7434C;What the hell, do you think I'm made of fuel? Go mining!") | |
self.logger.info("Gave fuel to %s.", self.protocol.player.name) | |
else: | |
self.protocol.send_chat_message("^#F7434C;What the hell, do you think I'm made of fuel? Go mining!") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from base_plugin import SimpleCommandPlugin | |
from utility_functions import give_item_to_player | |
from plugins.core.player_manager import permissions, UserLevels | |
from time import time | |
class FuelGiver(SimpleCommandPlugin): | |
""" | |
Welcomes new players by giving them fuel to leave the spawn world. | |
""" | |
name = "fuelgiver_plugin" | |
depends = ["command_dispatcher", "player_manager"] | |
commands = ["fuel"] | |
auto_activate = True | |
def activate(self): | |
super(FuelGiver, self).activate() | |
self.player_manager = self.plugins['player_manager'].player_manager | |
@permissions(UserLevels.GUEST) | |
def fuel(self, data): | |
"""Gives you some fuel items (only once). Syntax: /fuel""" | |
try: | |
my_storage = self.protocol.player.storage | |
except AttributeError: | |
self.logger.debug("Tried to give item to non-existent protocol.") | |
return | |
if not 'last_given_fuel' in my_storage or int(my_storage['last_given_fuel']) <= int(time.time()) - 86400: | |
my_storage['last_given_fuel'] = str(time.time()) | |
give_item_to_player(self.protocol, "fillerup", 1) | |
self.protocol.player.storage = my_storage | |
self.protocol.send_chat_message("^#F7434C;What the hell, do you think I'm made of fuel? Go mining!") | |
self.logger.info("Gave fuel to %s.", self.protocol.player.name) | |
else: | |
self.protocol.send_chat_message("^#F7434C;What the hell, do you think I'm made of fuel? Go mining!") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment