本文整理汇总了Java中org.bukkit.permissions.PermissionDefault类的典型用法代码示例。如果您正苦于以下问题:Java PermissionDefault类的具体用法?Java PermissionDefault怎么用?Java PermissionDefault使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissionDefault类属于org.bukkit.permissions包,在下文中一共展示了PermissionDefault类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCraft
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@EventHandler
public void onCraft(CraftItemEvent e)
{
Player p = (Player) e.getWhoClicked();
if(e.getRecipe() instanceof ShapedRecipe)
{
ShapedRecipe sr = (ShapedRecipe) e.getRecipe();
if(Bukkit.getBukkitVersion().contains("1.11"))
{
for(BagBase bb : Util.getBags())
{
if(((ShapedRecipe)bb.getRecipe()).getShape().equals(sr.getShape()))
{
if(!hasPermission(new Permission("bag.craft." + bb.getName(), PermissionDefault.TRUE), p))
e.setCancelled(true);
}
}
}
else
if(sr.getKey().getNamespace().startsWith("bag_"))
{
if(!hasPermission(new Permission("bag.craft." + sr.getKey().getKey(), PermissionDefault.TRUE), p))
e.setCancelled(true);
}
}
}
示例2: onEnable
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Override
public void onEnable() {
// Ensure parsing errors show in the console on Lobby servers,
// since PGM is not around to do that.
mapdevLogger.setUseParentHandlers(true);
this.getServer().getPluginManager().registerEvents(new EnvironmentControlListener(), this);
this.getServer().getPluginManager().registerEvents(new Gizmos(), this);
this.getServer().getMessenger().registerOutgoingPluginChannel(this, BUNGEE_CHANNEL);
this.setupScoreboard();
this.loadConfig();
for(Gizmo gizmo : Gizmos.gizmos) {
Bukkit.getPluginManager().addPermission(new Permission(gizmo.getPermissionNode(), PermissionDefault.FALSE));
}
Settings settings = new Settings(this);
settings.register();
navigatorInterface.setOpenButtonSlot(Slot.Hotbar.forPosition(0));
}
示例3: enable
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Override
public void enable() {
final PermissionAttachment attachment = Bukkit.getConsoleSender().addAttachment(plugin);
Stream.of(
PERMISSION,
PERMISSION_GET,
PERMISSION_SET,
PERMISSION_ANY,
PERMISSION_ANY_GET,
PERMISSION_ANY_SET,
PERMISSION_IMMEDIATE
).forEach(name -> {
final Permission permission = new Permission(name, PermissionDefault.FALSE);
pluginManager.addPermission(permission);
attachment.setPermission(permission, true);
});
}
示例4: registerPermission
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
public static Permission registerPermission(Permission perm, boolean withLegacy) {
Permission result = perm;
try {
Bukkit.getPluginManager().addPermission(perm);
} catch (IllegalArgumentException ex) {
result = Bukkit.getPluginManager().getPermission(perm.getName());
}
if (withLegacy) {
Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
legacy.getChildren().put(result.getName(), true);
registerPermission(perm, false);
}
return result;
}
示例5: processPermission
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
/**
* Processes a command.
*
* @param permissionAnnotation The annotation.
* @return The generated permission metadata.
*/
protected Map<String, Object> processPermission (Permission permissionAnnotation) {
Map<String, Object> permission = new HashMap<> ();
if (!"".equals (permissionAnnotation.description ())) {
permission.put ("description", permissionAnnotation.description ());
}
if (PermissionDefault.OP != permissionAnnotation.defaultValue ()) {
permission.put ("default", permissionAnnotation.defaultValue ().toString ().toLowerCase ());
}
if (permissionAnnotation.children ().length > 0) {
Map<String, Boolean> childrenList = new HashMap<> ();
for (ChildPermission childPermission : permissionAnnotation.children ()) {
childrenList.put (childPermission.value (), childPermission.inherit ());
}
permission.put ("children", childrenList);
}
return permission;
}
示例6: onCommand
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("cloudpacks")) {
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
sendHelp(sender);
return true;
}
if (args.length >= 1) {
if (args[0].equalsIgnoreCase("list")) {
if (args.length >= 2) {
if (sender.hasPermission(new Permission("cloudpacks.list.other", PermissionDefault.OP))) {
OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]);
}
}
} else if (args[0].equalsIgnoreCase("give")) {
} else if (args[0].equalsIgnoreCase("givekey")) {
}
}
}
return true;
}
示例7: registerPermissions
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
/**
* Registers permissions that depend on the user's configuration file (for MultipleAchievements; for instance for
* stone breaks, achievement.count.breaks.stone will be registered).
*/
private void registerPermissions() {
getLogger().info("Registering permissions...");
PluginManager pluginManager = getServer().getPluginManager();
for (MultipleAchievements category : MultipleAchievements.values()) {
for (String section : config.getConfigurationSection(category.toString()).getKeys(false)) {
int startOfMetadata = section.indexOf(':');
if (startOfMetadata > -1) {
// Permission ignores metadata (eg. sand:1) for Breaks, Places and Crafts categories.
section = section.substring(0, startOfMetadata);
}
if (category == MultipleAchievements.PLAYERCOMMANDS) {
// Permissions don't take spaces into account for this category.
section = StringUtils.replace(section, " ", "");
}
// Bukkit only allows permissions to be set once, check to ensure they were not previously set when
// performing /aach reload.
if (pluginManager.getPermission(category.toPermName() + "." + section) == null) {
pluginManager.addPermission(
new Permission(category.toPermName() + "." + section, PermissionDefault.TRUE));
}
}
}
}
示例8: registerPermissions
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
public static Permission registerPermissions(Permission parent) {
Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all vanilla minecraft commands", parent);
DefaultPermissions.registerPermission(PREFIX + "kill", "Allows the user to commit suicide", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "me", "Allows the user to perform a chat action", PermissionDefault.TRUE, commands);
DefaultPermissions.registerPermission(PREFIX + "tell", "Allows the user to privately message another player", PermissionDefault.TRUE, commands);
DefaultPermissions.registerPermission(PREFIX + "say", "Allows the user to talk as the console", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "give", "Allows the user to give items to players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "teleport", "Allows the user to teleport players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "kick", "Allows the user to kick players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "xp", "Allows the user to give themselves or others arbitrary values of experience", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "toggledownfall", "Allows the user to toggle rain on/off for a given world", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "defaultgamemode", "Allows the user to change the default gamemode of the server", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "seed", "Allows the user to view the seed of the world", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "effect", "Allows the user to add/remove effects on players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(PREFIX + "selector", "Allows the use of selectors", PermissionDefault.OP, commands);
commands.recalculatePermissibles();
return commands;
}
示例9: registerPermissions
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
public static void registerPermissions() {
addPermission(new Permission("zephyrus.command.spelltome", "Permission to use the '/spelltome' command", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.teach", "Permission to use the '/teach' command", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.aspects", "Permission to use the '/aspects' command", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.bind", "Permission to use the '/bind' command", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.book", "Permission to use the '/book' command", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.cast", "Permission to use the '/cast' command", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.level", "Permission to check level with '/level'", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.level.add", "Permission to increase level with '/level add'", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.level.other", "Permission to check other player's level with '/level <player>'", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.mana", "Permission to check mana with '/mana'", PermissionDefault.TRUE));
addPermission(new Permission("zephyrus.command.mana.restore", "Permission to restore mana with '/mana restore'", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.mana.other", "Permission to check other player's mana with '/mana <player>'", PermissionDefault.OP));
addPermission(new Permission("zephyrus.command.book.bypass", "Permission to ignore the book limit of '/book'", PermissionDefault.FALSE));
addPermission(new Permission("zephyrus.shop.create", "Allows user to create shops", PermissionDefault.OP));
addPermission(new Permission("zephyrus.shop.use", "Allows user to use shops", PermissionDefault.TRUE));
for (Permission permission : permissions) {
Bukkit.getPluginManager().addPermission(permission);
}
}
示例10: registerSpell
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Override
public void registerSpell(Spell spell) {
if (spellConfig.getConfig().getBoolean(spell.getDefaultName() + ".Enabled")) {
this.spellList.add(spell);
PermissionsManager.addPermission(new Permission("zephyrus.spell.learn." + spell.getDefaultName().toLowerCase()));
PermissionsManager.addPermission(new Permission("zephyrus.spell.cast." + spell.getDefaultName().toLowerCase(),
"Permission to cast the " + spell.getDefaultName() + " spell", PermissionDefault.FALSE));
if (spell instanceof Configurable) {
((Configurable) spell).loadConfiguration(spellConfig.getConfig().getConfigurationSection(
spell.getDefaultName()));
}
if (spell instanceof Listener) {
Bukkit.getPluginManager().registerEvents((Listener) spell, Zephyrus.getPlugin());
}
}
}
示例11: UpdateChecker
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
public UpdateChecker(Plugin plugin, String spigotFullId) {
this.plugin = plugin;
this.spigotId = spigotFullId;
try {
this.spigotUrl = new URL("https://www.spigotmc.org/resources/" + spigotId + "/");
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid spigot id: " + spigotId);
}
this.logger = plugin.getLogger();
permission = new Permission(plugin.getName() + ".update");
permission.setDefault(PermissionDefault.OP);
Bukkit.getPluginManager().addPermission(permission);
setInterval(20*60*30);//30 minutes
message = buildMessage();
}
示例12: ChannelMatchModule
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Inject ChannelMatchModule(Match match, Plugin plugin) {
this.matchListeningPermission = new Permission("pgm.chat.all." + match.getId() + ".receive", PermissionDefault.FALSE);
final OnlinePlayerMapAdapter<Boolean> map = new OnlinePlayerMapAdapter<>(plugin);
map.enable();
this.teamChatters = new DefaultMapAdapter<>(map, true, false);
}
示例13: configure
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Override
protected void configure() {
requestStaticInjection(RaindropUtil.class);
new PluginFacetBinder(binder())
.register(RaindropCommands.class);
final PermissionBinder permissions = new PermissionBinder(binder());
for(int i = RaindropConstants.MULTIPLIER_MAX; i > 0; i = i - RaindropConstants.MULTIPLIER_INCREMENT) {
permissions.bindPermission().toInstance(new Permission("raindrops.multiplier." + i, PermissionDefault.FALSE));
}
}
示例14: updatePermission
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
private boolean updatePermission(String name, Map<String, Boolean> before, Map<String, Boolean> after) {
if(Objects.equals(before, after)) return false;
final Permission perm = new Permission(name, PermissionDefault.FALSE, after);
pluginManager.removePermission(perm);
pluginManager.addPermission(perm);
return true;
}
示例15: testValueFromEnum
import org.bukkit.permissions.PermissionDefault; //导入依赖的package包/类
@Test
public void testValueFromEnum() throws InputException {
Class[] inputTypes = {
WeatherType.class,
EquipmentSlot.class,
MainHand.class,
PermissionDefault.class
};
String[] input = {
"downfall",
"HeAd",
"lEfT",
"NOT_OP"
};
Object[] output = InputFormatter.getTypesFromInput(inputTypes, Arrays.asList(input), null);
// First let's make sure we didn't lose anything, or get anything
assertEquals(inputTypes.length, output.length);
// Next let's make sure everything is the right type
assertTrue(output[0] instanceof WeatherType);
assertTrue(output[1] instanceof EquipmentSlot);
assertTrue(output[2] instanceof MainHand);
assertTrue(output[3] instanceof PermissionDefault);
// Finally, let's make sure the values are correct
assertSame(output[0], WeatherType.DOWNFALL);
assertSame(output[1], EquipmentSlot.HEAD);
assertSame(output[2], MainHand.LEFT);
assertSame(output[3], PermissionDefault.NOT_OP);
}