TimedCreative

Discussion in 'Archived: Plugin Requests' started by Archie, Apr 9, 2013.

  1. Offline

    Archie

    Plugin category: ADMN

    Suggested name: TimedCreative

    What I want: I want a plugin that can give someone creative for a limited amount of time. Just a simple light-weight plugin.

    Ideas for commands: /tc <player> <time in seconds>

    Ideas for permissions: tc.use - can use the command above

    When I'd like it by: asap.

    Thanks! :)
     
  2. Offline

    RunningDeath16

    Going to create this tomorrow.
     
  3. Offline

    Vortextez

    I would like to use this too :)
     
  4. Offline

    Archie

    Hey, how's the plugin coming?
     
  5. Offline

    Hollasch

    I can do this in 5 minutes ;)

    I finished this plugin, I'm going to upload to dev bukkit, show you the link when it's done

    http://dev.bukkit.org/server-mods/timedcreative/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    RunningDeath16

    Sry, had no time for that.
     
  7. Offline

    Archie

  8. Offline

    Hollasch

    I don't know if this is good enough.... Here it is :)



    package me.imodzombies4fun.timedcreative;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class TimedCreative extends JavaPlugin {

    @SuppressWarnings("unused")
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
    Player player = (Player)sender;
    if (cmd.getName().equalsIgnoreCase("tc")) {
    if (player.hasPermission("tc.use")) {
    if (args.length == 0) {
    player.sendMessage(ChatColor.RED+"Usage: /tc <player> <time in seconds>");
    return true;
    }
    else {
    if (args.length == 1) {
    player.sendMessage(ChatColor.RED+"Please specify a time!");
    return true;
    }
    else {
    String pName = args[0];
    try { Bukkit.getPlayer(pName); } catch (Exception e) { player.sendMessage(ChatColor.RED+"No such player!"); return true;}
    final Player forCreative = Bukkit.getPlayer(pName);
    if (forCreative == null) {
    player.sendMessage(ChatColor.RED+"No such player!"); return true;
    }
    try { int i = Integer.parseInt(args[1]); } catch (Exception e) { player.sendMessage(ChatColor.RED+args[1]+" is not a valid time!"); return true;}
    int time = Integer.parseInt(args[1]);
    forCreative.setGameMode(GameMode.CREATIVE);
    player.sendMessage(ChatColor.RED+"Putting "+forCreative.getName()+" in creative mode for "+time+" seconds!");
    player.sendMessage(ChatColor.RED+"You have been put in creative for "+time+" seconds!");
    getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {

    @Override
    public void run() {
    forCreative.setGameMode(GameMode.SURVIVAL);
    forCreative.sendMessage(ChatColor.RED+"Your time is up! Back to survival.");
    }

    }, time*20);
    return true;
    }
    }
    }
    player.sendMessage(ChatColor.RED+"You do not have permission to do this!");
    return true;
    }
    }
    if (args.length == 0) {
    System.out.println(ChatColor.RED+"Usage: /tc <player> <time in seconds>");
    return true;
    }
    if (args.length == 1) {
    System.out.println(ChatColor.RED+"Please specify a time!");
    }
    String pName = args[0];
    try { Bukkit.getPlayer(pName); } catch (Exception e) { System.out.println(ChatColor.RED+"No such player!"); return true;}
    final Player forCreative = Bukkit.getPlayer(pName);
    try { int i = Integer.parseInt(args[1]); } catch (Exception e) { System.out.println(ChatColor.RED+args[1]+" is not a valid time!"); return true;}
    int time = Integer.parseInt(args[1]);
    forCreative.setGameMode(GameMode.CREATIVE);
    forCreative.sendMessage(ChatColor.RED+"You have been put in creative for "+time+" seconds!");
    getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {

    @Override
    public void run() {
    forCreative.setGameMode(GameMode.SURVIVAL);
    forCreative.sendMessage(ChatColor.RED+"Your time is up! Back to survival.");
    }

    }, time*20);
    return true;
    }
    }
     

Share This Page