Java Code Examples for org.bukkit.event.HandlerList.unregisterAll()

The following are Jave code examples for showing how to use unregisterAll() of the org.bukkit.event.HandlerList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GhostScavengerHunt   File: GhostSkull.java   Source Code and License Vote up 6 votes
@EventHandler
public void onSkullBreak(BlockBreakEvent event) {
    if(!LocationUtils.center(event.getBlock().getLocation()).equals(LocationUtils.center(this.location))) return;
    if(!event.getPlayer().hasPermission("ghostskull.break")) {
        event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', this.getPlugin().getMessageFile().getString("cannot-break-skull-message")));
        event.setCancelled(true);
    } else {
        HandlerList.unregisterAll(this);
        plugin.getGhostSkulls().remove(this);
        plugin.getDataFile().set(this.uuid.toString(), null);
        try {
            plugin.getDataFile().save(plugin.getF_dataFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
        event.getPlayer().sendMessage(ChatColor.GREEN + "Ghost Skull has been deleted.");
    }
}
 
Example 2
Project: Ourtown   File: OurTown.java   Source Code and License Vote up 5 votes
public void reload() {
    getServer().getScheduler().cancelTasks(this);
    getCommand("town").setExecutor(null);
    getCommand("town").setTabCompleter(null);
    HandlerList.unregisterAll(this);
    onEnable();
}
 
Example 3
Project: CustomRecipes   File: WorldAdder.java   Source Code and License Vote up 5 votes
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof WorldRecipeHolder) {
		WorldRecipeHolder holder = (WorldRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		WorldRecipe nmsRecipe = holder.toRecipe();
		CRWorldRecipe worldRecipe = new CRWorldRecipe(nmsRecipe);
		List<List<String>> recipeIngredients = worldRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(worldRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, worldRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded world recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("world", worldRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a world recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
Example 4
Project: FactionsXL   File: FactionsXL.java   Source Code and License Vote up 5 votes
/**
 * load / reload a new instance of ChatListener and register it
 */
public void loadChatListener() {
    if (chatListener != null) {
        HandlerList.unregisterAll(chatListener);
    }
    chatListener = new ChatListener();
    manager.registerEvents(chatListener, this);
}
 
Example 5
Project: CustomRecipes   File: ShapedAdder.java   Source Code and License Vote up 5 votes
@EventHandler
public void onInventoryClose(InventoryCloseEvent event) {
	if (event.getInventory().getHolder() instanceof ShapedRecipeHolder) {
		ShapedRecipeHolder holder = (ShapedRecipeHolder) event.getInventory().getHolder();
		if (holder != this) return;

		Inventory inventory = event.getInventory();
		if (InventoryUtils.isEmpty(inventory)) {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Do you seriously want to create a recipe without ingredients?");
			return;
		}

		ShapedRecipes nmsRecipe = holder.toRecipe();
		CRShapedRecipe<ShapedRecipes> shapedRecipe = new CRShapedRecipe<>(nmsRecipe);
		List<List<String>> recipeIngredients = shapedRecipe.getIngredients().stream()
				.map((CRChoiceIngredient ingr) -> ingr.getChoices().stream()
						.map(InventoryUtils::getItemName).collect(Collectors.toList()))
				.collect(Collectors.toList());
		String recipeString = recipeIngredients + "" +
				ChatColor.RESET + " -> " +
				InventoryUtils.getItemName(shapedRecipe.getResult());

		boolean success = holder.plugin.getCraftingManager().addRecipe(holder.key, nmsRecipe, shapedRecipe);
		if (success) {
			holder.callbackPlayer.sendMessage(String.format("%sAdded shaped recipe: %s%s%s!",
					ChatColor.GREEN, ChatColor.WHITE, recipeString, ChatColor.WHITE));
			plugin.saveCraftingRecipeFile("shaped", shapedRecipe);
		} else {
			holder.callbackPlayer.sendMessage(ChatColor.RED + "Couldn't create a shaped recipe. Possibly a duplicate key.");
		}

		HandlerList.unregisterAll(holder);
	}
}
 
Example 6
Project: VoxelGamesLibv2   File: Ability.java   Source Code and License Vote up 5 votes
public void unregister(boolean removeTickable) {
    HandlerList.unregisterAll(this);
    List<Game> games = injector.getInstance(GameHandler.class).getGames(affected.getUuid(), false);

    if (games.size() == 1) {
        Game game = games.get(0);

        if (removeTickable) {
            game.getActivePhase().removeTickable(identifier);
        }
    }
}
 
Example 7
Project: FactionsXL   File: FactionsXL.java   Source Code and License Vote up 5 votes
/**
 * load / reload a new instance of EntityProtectionListener and register it
 */
public void loadEntityProtectionListener() {
    if (entityProtectionListener != null) {
        HandlerList.unregisterAll(entityProtectionListener);
    }
    entityProtectionListener = new EntityProtectionListener();
    manager.registerEvents(entityProtectionListener, this);
}
 
Example 8
Project: ProjectAres   File: MatchTabManager.java   Source Code and License Vote up 5 votes
public void disable() {
    if(this.renderTask != null) {
        this.renderTask.cancel();
        this.renderTask = null;
    }

    HandlerList.unregisterAll(this);
}
 
Example 9
Project: FactionsXL   File: FactionsXL.java   Source Code and License Vote up 5 votes
@Override
public void onDisable() {
    if (instance != null) {
        saveData();
        backupData();
    }
    HandlerList.unregisterAll(this);
    getServer().getScheduler().cancelTasks(this);
}
 
Example 10
Project: Chambers   File: ScoreboardManager.java   Source Code and License Vote up 5 votes
void unregister() {
	scoreboards.forEach((uuid, scoreboard) -> {
		scoreboard.disable();
	});
	HandlerList.unregisterAll(this);
	updateTask.cancel();
}
 
Example 11
Project: ChatModerator   File: ChatModeratorPlugin.java   Source Code and License Vote up 5 votes
@Override
public void onDisable() {
    for (Listener listener : this.listeners) {
        if (listener instanceof ChatModeratorListener) {
            ((ChatModeratorListener) listener).getZoneManager().unRegisterAllZones();
            ((ChatModeratorListener) listener).getFilterManager().unRegisterAllFilters();
        }
        HandlerList.unregisterAll(listener);
    }
    this.playerManager = null;
    this.configuration = null;
}
 
Example 12
Project: OpenUHC   File: BlindnessModule.java   Source Code and License Vote up 4 votes
@Override
public void onDisable() {
  HandlerList.unregisterAll(this);
}
 
Example 13
Project: ZentrelaCore   File: AbstractManager.java   Source Code and License Vote up 4 votes
protected void unload(SakiCore plugin) {
    HandlerList.unregisterAll(this);
}
 
Example 14
Project: NineSlots   File: NineSlotsCommand.java   Source Code and License Vote up 4 votes
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (args.length == 0) {
        sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
        return true;
    }

    if (args[0].equalsIgnoreCase("info")) {
        sender.sendMessage(Main.PREFIX + "Plugin creator: §aLeonTG");
        sender.sendMessage(Main.PREFIX + "Version: §a" + plugin.getDescription().getVersion());
        sender.sendMessage(Main.PREFIX + "Description:");
        sender.sendMessage("§8» §f" + plugin.getDescription().getDescription());
        return true;
    }

    if (args[0].equalsIgnoreCase("enable")) {
        if (!sender.hasPermission(PERMISSION)) {
            sender.sendMessage(ChatColor.RED + "You don't have permission.");
            return true;
        }

        if (enabled) {
            sender.sendMessage(Main.PREFIX + "Nine Slots is already enabled.");
            return true;
        }

        plugin.broadcast(Main.PREFIX + "Nine Slots has been enabled.");
        enabled = true;

        Bukkit.getPluginManager().registerEvents(listener, plugin);

        task = new BukkitRunnable() {
            @Override
            public void run() {
                for (Player online : Bukkit.getOnlinePlayers()) {
                    for (int i = 9; i < 36; i++) {
                        online.getInventory().setItem(i, Main.BLOCKED_ITEM);
                    }
                }
            }
        };

        task.runTaskTimer(plugin, 0L, 100L);
        return true;
    }

    if (args[0].equalsIgnoreCase("disable")) {
        if (!sender.hasPermission(PERMISSION)) {
            sender.sendMessage(ChatColor.RED + "You don't have permission.");
            return true;
        }

        if (!enabled) {
            sender.sendMessage(Main.PREFIX + "Nine Slots is not enabled.");
            return true;
        }

        plugin.broadcast(Main.PREFIX + "Nine Slots has been disabled.");
        enabled = false;

        HandlerList.unregisterAll(listener);

        if (task != null) {
            task.cancel();
        }

        task = null;
        return true;
    }

    sender.sendMessage(Main.PREFIX + "Usage: /nineslots <info|enable|disable>");
    return true;
}
 
Example 15
Project: OpenUHC   File: Bats.java   Source Code and License Vote up 4 votes
@Override
public void onDisable() {
  HandlerList.unregisterAll(this);
}
 
Example 16
Project: Warzone   File: WoolObjective.java   Source Code and License Vote up 4 votes
public void unload() {
    HandlerList.unregisterAll(this);
}
 
Example 17
Project: CapCat   File: Capcat.java   Source Code and License Vote up 4 votes
public void reload() {
    HandlerList.unregisterAll(this);
    onEnable();
}
 
Example 18
Project: ProjectAres   File: ControlPoint.java   Source Code and License Vote up 4 votes
public void unregisterEvents() {
    HandlerList.unregisterAll(this.blockDisplay);
    HandlerList.unregisterAll(this.playerTracker);
}
 
Example 19
Project: OpenUHC   File: BenchBlitz.java   Source Code and License Vote up 4 votes
@Override
public void onDisable() {
  HandlerList.unregisterAll(this);
}
 
Example 20
Project: Sunscreen   File: Sunscreen.java   Source Code and License Vote up 2 votes
/**
 * Unregisters listeners and events.
 *
 * @author HomieDion
 * @since 1.0.0
 */
public void unregister() {
	HandlerList.unregisterAll(this);
	Bukkit.getScheduler().cancelTasks(this);
}