Giter VIP home page Giter VIP logo

itemmovedetectionlib's Introduction

Latest Maven Central Version GitHub Workflow Status

ItemMoveDetectionLib

A simple library to detect when a player removes or adds an item from their inventory.

Note: For GUI plugins and similar, you should use InventoryClickEvent instead of this library.

How to use

Getting the dependency

Gradle:

plugins {
    id 'com.github.johnrengelman.shadow' version '6.1.0'
}

shadowJar {
    // Replace [YOUR PACKAGE] with your base package (ex: me.dkim19375.bedwars)
    relocate 'me.dkim19375.itemmovedetectionlib', '[YOUR PACKAGE].itemmovedetectionlib'
}

repositories {
    mavenCentral()
}

dependencies {
    // Make sure to replace VERSION with the latest version
    implementation 'io.github.dkim19375:item-move-detection-lib:VERSION'
}

Or with maven, add the shade plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.1.1</version>
    <configuration>
        <relocations>
            <relocation>
                <pattern>me.dkim19375.itemmovedetectionlib</pattern>
                <shadedPattern>[YOUR PACKAGE].itemmovedetectionlib</shadedPattern> <!-- Replace package here here -->
            </relocation>
        </relocations>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Add the dependency:

<dependency>
    <groupId>io.github.dkim19375</groupId>
    <artifactId>item-move-detection-lib</artifactId>
    <version>VERSION</version> <!-- replace version here -->
</dependency>

Using the library

You have to register the library's events.

To do that you do ItemMoveDetectionLib.register().

This is a simple plugin to disable stealing items:

package me.dkim19375.coolplugin;

import me.dkim19375.itemmovedetectionlib.ItemMoveDetectionLib;
import me.dkim19375.itemmovedetectionlib.event.InventoryItemTransferEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public class CoolPlugin extends JavaPlugin implements Listener {
    @Override
    public void onEnable() {
        ItemMoveDetectionLib.register(this);
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    private void onTransfer(InventoryItemTransferEvent event) {
        if (event.getType().isFromOther()) {
            event.getPlayer().sendMessage(ChatColor.RED + "Don't steal!!");
            event.setCancelled(true);
        }
    }
}

itemmovedetectionlib's People

Contributors

dkim19375 avatar renovate[bot] avatar renovate-bot avatar

Watchers

 avatar

itemmovedetectionlib's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/gradle-test.yml
  • actions/checkout v4@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/setup-java v4
gradle
gradle.properties
settings.gradle.kts
build.gradle.kts
  • org.cadixdev.licenser 0.6.1
  • com.github.johnrengelman.shadow 8.1.1
  • io.github.gradle-nexus.publish-plugin 1.3.0
  • org.jetbrains:annotations 24.1.0
  • org.spigotmc:spigot-api 1.8.8-R0.1-SNAPSHOT
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.9

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.