Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,800 resources
01
Days
04
Hours
55
Mins
32
Secs

DisableEnderchest for Certain Groups

Status
This thread has been locked.

DwapDatBase

Feedback score
0
Posts
495
Reactions
89
Resources
0
Hi, I'm Dwap and I'll like to buy a plugin that disiable enderchest for certain groups (Must be compatible with GroupManager). The message when a player who is in a group that doesn't have permission for using the enderchest must be customizable. I'm willing to pay a small fee and if you're interested please comment down below <3
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Nagi

PM Only - No Skype
Supreme
Feedback score
12
Posts
535
Reactions
679
Resources
0
I got time right now. I can do it for free. I'm new to this site. Not sure where to upload the jar. Here's the code thou.

Code:
package com.kThisIsCvpv.NoEnderchests;

import java.io.File;
import java.io.IOException;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class NoEnderchests extends JavaPlugin implements Listener {

    private File configFile = new File(this.getDataFolder().getAbsolutePath() + "/config.yml");
    private FileConfiguration config = new YamlConfiguration();
    private String disabledMessage;
    private String permissionNode;

    public void onEnable() {
        try {

            if (!configFile.exists()) {
                configFile.getParentFile().mkdirs();
                configFile.createNewFile();
            }

            config.load(configFile);

            if (config.getString("NoPermsMessage") == null) {
                config.set("NoPermsMessage", "&cYou do not have permissions to use this!");
                config.save(configFile);
            }

            if (config.getString("PermissionNode") == null) {
                config.set("PermissionNode", "enderchest.perm");
                config.save(configFile);
            }

            this.disabledMessage = ChatColor.translateAlternateColorCodes('&', config.getString("NoPermsMessage"));
            this.permissionNode = config.getString("PermissionNode");

            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            System.out.println("[NoEnderchests] The DisabledMessage is: " + this.disabledMessage);
            System.out.println("[NoEnderchests] The PermissionNode is: " + this.permissionNode);

        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }

    public void onDisable() {

    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onClick(PlayerInteractEvent evt) {
        final Player p = evt.getPlayer();

        if (evt.isCancelled())
            return;

        if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
            final Block block = evt.getClickedBlock();
            if(block.getType() == Material.ENDER_CHEST && (!(p.hasPermission(this.permissionNode)))){
                evt.setCancelled(true);
                p.sendMessage(this.disabledMessage);
            }
        }
    }
}
 

DwapDatBase

Feedback score
0
Posts
495
Reactions
89
Resources
0
I got time right now. I can do it for free. I'm new to this site. Not sure where to upload the jar. Here's the code thou.

Code:
package com.kThisIsCvpv.NoEnderchests;

import java.io.File;
import java.io.IOException;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class NoEnderchests extends JavaPlugin implements Listener {

    private File configFile = new File(this.getDataFolder().getAbsolutePath() + "/config.yml");
    private FileConfiguration config = new YamlConfiguration();
    private String disabledMessage;
    private String permissionNode;

    public void onEnable() {
        try {

            if (!configFile.exists()) {
                configFile.getParentFile().mkdirs();
                configFile.createNewFile();
            }

            config.load(configFile);

            if (config.getString("NoPermsMessage") == null) {
                config.set("NoPermsMessage", "&cYou do not have permissions to use this!");
                config.save(configFile);
            }

            if (config.getString("PermissionNode") == null) {
                config.set("PermissionNode", "enderchest.perm");
                config.save(configFile);
            }

            this.disabledMessage = ChatColor.translateAlternateColorCodes('&', config.getString("NoPermsMessage"));
            this.permissionNode = config.getString("PermissionNode");

            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            System.out.println("[NoEnderchests] The DisabledMessage is: " + this.disabledMessage);
            System.out.println("[NoEnderchests] The PermissionNode is: " + this.permissionNode);

        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }

    public void onDisable() {

    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onClick(PlayerInteractEvent evt) {
        final Player p = evt.getPlayer();

        if (evt.isCancelled())
            return;

        if (evt.getAction() == Action.RIGHT_CLICK_BLOCK) {
            final Block block = evt.getClickedBlock();
            if(block.getType() == Material.ENDER_CHEST && (!(p.hasPermission(this.permissionNode)))){
                evt.setCancelled(true);
                p.sendMessage(this.disabledMessage);
            }
        }
    }
}
Can you upload to mediafire?
 

Stephen

Irrelevant ☕️
Deactivated
Feedback score
8
Posts
2,326
Reactions
1,412
Resources
0
Jesse, you're a noob... You could just ask for help on skype >.> Or not, that works too.
 
Status
This thread has been locked.
Top