Last active
August 29, 2015 13:57
-
-
Save drtshock/9839599 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# GiveBackStuffOnResets by drtshock | |
# This plugin is designed to execute commands when a player first joins the server based on their primary group. | |
# Great for giving people money and mcmmo etc. back on resets. | |
# Add as many groups as you want. Group names are case sensitive to what you have defined in your permissions plugin. | |
# Add commands to execute as a list below the key. | |
# Use {name} for the player's name. | |
default: | |
- "/give {name} diamond 1" |
This file contains hidden or 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
package com.drtshock.givebackstuffonresets; | |
import net.milkbowl.vault.permission.Permission; | |
import org.bukkit.Bukkit; | |
import org.bukkit.ChatColor; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import org.bukkit.event.player.PlayerJoinEvent; | |
import org.bukkit.plugin.RegisteredServiceProvider; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class GiveBackStuffOnResets extends JavaPlugin implements Listener { | |
private static Permission perms = null; | |
@Override | |
public void onEnable() { | |
saveDefaultConfig(); | |
getServer().getPluginManager().registerEvents(this, this); | |
setupPermissions(); | |
} | |
private boolean setupPermissions() { | |
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); | |
perms = rsp.getProvider(); | |
return perms != null; | |
} | |
@EventHandler | |
public void onJoin(PlayerJoinEvent event) { | |
if(event.getPlayer().hasPlayedBefore()) return; | |
String group = perms.getPrimaryGroup(event.getPlayer()); | |
if (getConfig().contains(group)) { | |
for (String s : getConfig().getStringList(group)) { | |
Bukkit.dispatchCommand(getServer().getConsoleSender(), s.replace("{name}", event.getPlayer().getName())); | |
} | |
} | |
} | |
@Override | |
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | |
reloadConfig(); | |
sender.sendMessage(ChatColor.GREEN + "Config reloaded"); | |
return true; | |
} | |
} |
This file contains hidden or 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
name: GiveBackStuffOnResets | |
author: drtshock | |
version: ${project.version} | |
main: com.drtshock.givebackstuffonresets.GiveBackStuffOnResets | |
depend: [Vault] | |
commands: | |
gbsor: | |
permission: gbsor.admin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment