當前位置: 首頁>>代碼示例>>Java>>正文


Java Permissible類代碼示例

本文整理匯總了Java中org.bukkit.permissions.Permissible的典型用法代碼示例。如果您正苦於以下問題:Java Permissible類的具體用法?Java Permissible怎麽用?Java Permissible使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Permissible類屬於org.bukkit.permissions包,在下文中一共展示了Permissible類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Override
public Map<Permissible, Boolean> get(Object key) {
    if (key == null || !(key instanceof String)) {
        return null;
    }

    String permission = ((String) key);

    Map<Permissible, Boolean> result = super.get(key);

    if (result == null) {
        // calculate a new map - always!
        result = new LPSubscriptionValueMap(permission);
        super.put(permission, result);
    } else if (!(result instanceof LPSubscriptionValueMap)) {
        // ensure return type is a LPSubscriptionMap
        result = new LPSubscriptionValueMap(permission, result);
        super.put(permission, result);
    }
    return result;
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:22,代碼來源:LPSubscriptionMap.java

示例2: inject

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
private void inject() throws Exception {
    PluginManager pluginManager = this.plugin.getServer().getPluginManager();

    if (!(pluginManager instanceof SimplePluginManager)) {
        this.plugin.getLog().severe("PluginManager instance is not a 'SimplePluginManager', instead: " + pluginManager.getClass());
        this.plugin.getLog().severe("Unable to inject LuckPerms Permission Subscription map.");
        return;
    }

    Object map = PERM_SUBS_FIELD.get(pluginManager);
    if (map instanceof LPSubscriptionMap) {
        return; // already injected
    }

    //noinspection unchecked
    Map<String, Map<Permissible, Boolean>> castedMap = (Map<String, Map<Permissible, Boolean>>) map;

    // make a new subscription map
    LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);

    // inject it
    PERM_SUBS_FIELD.set(pluginManager, newMap);
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:24,代碼來源:SubscriptionMapInjector.java

示例3: getUpdateText

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
public List<String> getUpdateText(Permissible player) {
    long yesterday = System.currentTimeMillis() - 1000l * 60 * 60 * 24;
    boolean isEnabled = lastNonNullGetUpdateText > yesterday;
    try {
        if (readerProvider == null) return null;
        if (!player.hasPermission(upgradePermission)) return null;
        lastNonNullGetUpdateText = System.currentTimeMillis();
        isEnabled = true;
        List<String> text;
        synchronized (this) {
            if (lastUpgradeCheck < yesterday) {
                enabled.set(1);
                lastUpgradeCheck = System.currentTimeMillis();
                asynchronousRunnableExecutor.runTaskAsynchronously(new GetLatestVersion());
            } else {
                enabled.set(0);
            }
            text = upgradeText;
        }
        return text;
    } finally {
        enabled.set(isEnabled ? 1 : 0);
    }
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:25,代碼來源:UpdateChecker.java

示例4: testRecentlyUpdated

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testRecentlyUpdated() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    updateChecker.lastUpgradeCheck = System.currentTimeMillis() - 1000l * 60 * 60 * 12;
    updateChecker.upgradeText = new ArrayList<String>();
    updateChecker.upgradeText.add("hello");

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(1, updateText.size());
    assertEquals("hello", updateText.get(0));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:17,代碼來源:UpdateCheckerTest.java

示例5: testUpdateContainsFrenchAndGerman

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testUpdateContainsFrenchAndGerman() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.25165825");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("French language option!", updateText.get(0));
    assertEquals("German language option!", updateText.get(1));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:18,代碼來源:UpdateCheckerTest.java

示例6: testUpdateContainsOnlyUnpredictedFeatures

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testUpdateContainsOnlyUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.5");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(1, updateText.size());
    assertEquals("New features!", updateText.get(0));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:17,代碼來源:UpdateCheckerTest.java

示例7: testUpdateContainsBugFixesAndUnpredictedFeatures

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testUpdateContainsBugFixesAndUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.7");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Bug fixes!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:18,代碼來源:UpdateCheckerTest.java

示例8: testUpdateContainsPotionsAndUnpredictedFeatures

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testUpdateContainsPotionsAndUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.37");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Potions!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:18,代碼來源:UpdateCheckerTest.java

示例9: testSNAPSHOT

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Test
public void testSNAPSHOT() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2-SNAPSHOT"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.37");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Potions!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
 
開發者ID:sciolizer,項目名稱:craftinomicon,代碼行數:18,代碼來源:UpdateCheckerTest.java

示例10: inject

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
public Permissible inject(Player player, Permissible permissible) throws NoSuchFieldException, IllegalAccessException {
    Field permField = null;
    try {
        permField = getPermissibleField(player);
    } catch (Exception e) {
    }
    if (permField == null) {
        return null;
    }
    Permissible oldPerm = (Permissible) permField.get(player);
    if (permissible instanceof PermissibleBase) {
        PermissibleBase newBase = (PermissibleBase) permissible;
        permField.set(player, newBase);
    }

    // Inject permissible
    permField.set(player, permissible);
    return oldPerm;
}
 
開發者ID:gustav9797,項目名稱:PowerfulPerms,代碼行數:20,代碼來源:PermissibleBaseInjector.java

示例11: isRecipeAllowedForPermissible

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
/**
 * Is the recipe allowed?
 *
 * @param permissible Permissible the permissible to check against
 * @param recipe      the recipe to check
 * @return boolean true if allowed, false if not
 */
private static boolean isRecipeAllowedForPermissible(Permissible permissible, Recipe recipe)
{
    Material result = recipe.getResult().getType();
    if(result == Material.SPECKLED_MELON && hasRecipeGotMaterial(recipe, Material.GOLD_NUGGET) && permissible.hasPermission(DISALLOW_OLD_GMELON)) {
        return false;
    }
    if(result == Material.SPECKLED_MELON && hasRecipeGotMaterial(recipe, Material.GOLD_BLOCK) && permissible.hasPermission(ALLOW_NEW_GMELON)) {
        return false;
    }
    if(result == Material.GOLDEN_CARROT && hasRecipeGotMaterial(recipe, Material.GOLD_NUGGET) && permissible.hasPermission(DISALLOW_OLD_GCARROT)) {
        return false;
    }
    if(result == Material.GOLDEN_CARROT && hasRecipeGotMaterial(recipe, Material.GOLD_INGOT) && permissible.hasPermission(ALLOW_NEW_GCARROT)) {
        return false;
    }
    //passed all checks
    return true;
}
 
開發者ID:Eluinhost,項目名稱:ultrahardcore,代碼行數:26,代碼來源:RecipeFeature.java

示例12: broadcast

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
@Override
public int broadcast(String message, String permission) {
    int count = 0;
    Set<Permissible> permissibles = getPluginManager().getPermissionSubscriptions(permission);

    for (Permissible permissible : permissibles) {
        if (permissible instanceof CommandSender && permissible.hasPermission(permission)) {
            CommandSender user = (CommandSender) permissible;
            user.sendMessage(message);
            count++;
        }
    }

    return count;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:16,代碼來源:CraftServer.java

示例13: inject

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
/**
 * Inject new permissible base into given commandSender
 *
 * @param sender      The sender
 * @param permissible The permissible base
 * @return The result
 */
public static boolean inject(CommandSender sender, Permissible permissible) {
    Field f = getPermissibleField(sender);

    try {
        f.set(sender, permissible);
        return true;
    }
    catch(IllegalAccessException e) {
        return false;
    }
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:19,代碼來源:PermissionInjector.java

示例14: getPermissible

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
/**
 * Get permissible object from given sender
 *
 * @param sender The sender
 * @return The permissible object
 */
public static Permissible getPermissible(CommandSender sender) {
    Field f = getPermissibleField(sender);

    if(f == null) {
        return null;
    }
    try {
        return (Permissible) f.get(sender);
    }
    catch(IllegalAccessException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:21,代碼來源:PermissionInjector.java

示例15: onJoin

import org.bukkit.permissions.Permissible; //導入依賴的package包/類
/**
 * When the player joins the server
 * <p>
 * SERVER JOIN
 */
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerJoinEvent event) {
    if(!Moo.getInstance().isConnected()) return;
    event.setJoinMessage(null);
    Player player = event.getPlayer();

    PlayerData data = new PlayerData();
    data.setUuid(player.getUniqueId());
    data.setLastName(player.getName());
    data.setLastIp(player.getAddress().getHostString());

    // changes state
    Permissible oldPermissible = PermissionInjector.getPermissible(player);
    CustomPermissible customPermissible = new CustomPermissible(player, data.getUuid(), oldPermissible);
    PermissionInjector.inject(player, customPermissible);

    MooQueries.getInstance().changePlayerState(data, PacketPlayerState.State.JOIN_SERVER, response -> {
    });

    // UPDATE SERVER INFO
    Lightning.getInstance().updateServerInfo();

    // SET JOIN MESSAGE
    String playerName = MooQueries.getInstance().getGroup(player.getUniqueId()).getColor() + player.getName();
    Bukkit.getServer().broadcastMessage(LanguageManager.get("join-message-pattern", playerName));
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:32,代碼來源:ServerListener.java


注:本文中的org.bukkit.permissions.Permissible類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。