API

The source for this plugin is available on GitHub
- VoxelSniper is also on GitHub
The methods below are only valid in versions 0.3.4 and above

A quick example

First off, you will want to get an instance of the plugin:

1
2
3
4
5
6
7
Plugin VSRPlugin = Bukkit.getServer().getPluginManager().getPlugin("VoxelSniperRegions");
if ((VSRPlugin!=null) && VSRPlugin.isEnabled()) {
VoxelSniperRegions VSR = (VoxelSniperRegions) VSRPlugin;

// You can use the VSR variable to do stuff with VoxelSniperRegions... 

}

With the VSR variable you can do a bunch of different things.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
VSR.getMask(Player); //Get the VoxelMask for a player (may be null)
VSR.getMaskedPlayerNames(); //Get the players that currently have a mask
VSR.getMasks(); //Get all the current VoxelMasks in use

//Remove a player's mask.
VSR.removeMask(Player);
//Set a player's mask
VSR.setMask(Player, VoxelMask);
//force an update of a player's mask based on a location
VSR.updateMask(Player, Location);

VSR.getMaskManager(Plugin) //Get the mask manager for a plugin
VSR.getMaskManager(String) //Get the mask manager for a plugin name (string)

VSR.getManagerKeys() //get a list of plugin names which have a mask manager
VSR.getManagerPlugins() //get a list of plugins with a mask manager
VSR.getManagers() //get a list of current VoxelMaskManager objects

//remove a VoxelMaskManager
VSR.removeMaskManager(Plugin);
VSR.removeMaskManager(String);
VSR.removeMaskManager(VoxelMaskManager);

VSR.GetMsg(String) //Get a message from the language file for VoxelSniperRegions

Below is an example of how the plugin can restrict VoxelSniper to a plotme plot:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
//The following shows an example of adding a VoxelMaskManager for plotme
VSR.addMaskManager(new VoxelMaskManager(this) {
    @Override
    public VoxelMask getMask(Player arg0, Location arg1) {
        final Plot plotid = PlotManager.getPlotById(location);
        if (plotid==null) {
            return null;
        }
        boolean isallowed = PlotManager.getPlotById(location).isAllowed(player.getName());
        if (isallowed) {
            Location pos1 = new Location(location.getWorld(),PlotManager.bottomX(plotid.id,player.getWorld()),0,PlotManager.bottomZ(plotid.id,player.getWorld()));
            Location pos2 = new Location(location.getWorld(),PlotManager.topX(plotid.id,player.getWorld()),256,PlotManager.topZ(plotid.id,player.getWorld()));
            return new VoxelMask(pos1, pos2) {
                @Override
                public String getName() {
                    return plotid.id;
                }
            };
        }
        return null;
    }
});

The whole file:

Click here for the file below

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Plugin VSRPlugin = Bukkit.getServer().getPluginManager().getPlugin("VoxelSniperRegions");
if ((VSRPlugin!=null) && VSRPlugin.isEnabled()) {
    VoxelSniperRegions VSR = (VoxelSniperRegions) VSRPlugin;
    
    VSR.getMask(Player); //Get the VoxelMask for a player (may be null)
    VSR.getMaskedPlayerNames(); //Get the players that currently have a mask
    VSR.getMasks(); //Get all the current VoxelMasks in use
    
    //Remove a player's mask.
    VSR.removeMask(Player);
    //Set a player's mask
    VSR.setMask(Player, VoxelMask);
    //force an update of a player's mask based on a location
    VSR.updateMask(Player, Location);
    
    VSR.getMaskManager(Plugin) //Get the mask manager for a plugin
    VSR.getMaskManager(String) //Get the mask manager for a plugin name (string)
    
    VSR.getManagerKeys() //get a list of plugin names which have a mask manager
    VSR.getManagerPlugins() //get a list of plugins with a mask manager
    VSR.getManagers() //get a list of current VoxelMaskManager objects
    
    //remove a VoxelMaskManager
    VSR.removeMaskManager(Plugin);
    VSR.removeMaskManager(String);
    VSR.removeMaskManager(VoxelMaskManager);
    
    VSR.GetMsg(String) //Get a message from the language file for VoxelSniperRegions
    
    
    //The following shows an example of adding a VoxelMaskManager for plotme
    VSR.addMaskManager(new VoxelMaskManager(this) {
        @Override
        public VoxelMask getMask(Player arg0, Location arg1) {
            final Plot plotid = PlotManager.getPlotById(location);
            if (plotid==null) {
                return null;
            }
            boolean isallowed = PlotManager.getPlotById(location).isAllowed(player.getName());
            if (isallowed) {
                Location pos1 = new Location(location.getWorld(),PlotManager.bottomX(plotid.id,player.getWorld()),0,PlotManager.bottomZ(plotid.id,player.getWorld()));
                Location pos2 = new Location(location.getWorld(),PlotManager.topX(plotid.id,player.getWorld()),256,PlotManager.topZ(plotid.id,player.getWorld()));
                return new VoxelMask(pos1, pos2) {
                                        //The getName() method is optional.
                    @Override
                    public String getName() {
                        return plotid.id;
                    }
                };
            }
            return null;
        }
    });
}

Comments

Posts Quoted:
Reply
Clear All Quotes