Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhigyaKrishna committed Dec 4, 2021
0 parents commit 0fb4d7b
Show file tree
Hide file tree
Showing 200 changed files with 27,291 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Format

on:
push:
branches: [ main ]

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: axel-op/googlejavaformat-action@v3
with:
args: "--skip-sorting-imports --replace --aosp"
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Common working directory
run/
32 changes: 32 additions & 0 deletions action-item/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>CoreLib</artifactId>
<groupId>com.pepedevs</groupId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>action-item</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>com.pepedevs</groupId>
<artifactId>utils</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.pepedevs</groupId>
<artifactId>event-utils</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.pepedevs.corelib.item;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;

import java.util.List;

public interface ActionItem {

/**
* Gets the display name of the Action Item.
*
* <p>
*
* @return Display name of the Action Item
*/
public String getDisplayName();

/**
* Gets the lore of the Action Item.
*
* <p>
*
* @return Lore of the Action Item
*/
public List<String> getLore();

/**
* Gets the material of the Action Item.
*
* <p>
*
* @return Material of the Action Item
*/
public Material getMaterial();

/**
* Gets the {@link EventPriority} for the Action Item.
*
* <p>
*
* @return Event priority of the Action Item
*/
public EventPriority getPriority();

/**
* Get the ItemStack of the Action Item.
*
* <p>
*
* @return ItemStack of the Action Item
*/
public ItemStack toItemStack();

/**
* Checks if the provided ItemStack is of this Action Item.
*
* <p>
*
* @param item ItemStack to check
* @return <strong>{@code true}</strong> if the ItemStack is of this Action Item, else false
*/
public boolean isThis(ItemStack item);

/**
* Register the action to be performed on interact with this item.
*
* <p>
*
* @param player Player who performs the action
* @param action {@link EnumAction} performed on this item
* @param event {@link PlayerInteractEvent} triggered in the action event
*/
public void onActionPerform(Player player, EnumAction action, PlayerInteractEvent event);

/** Enumeration for actions defined for an item. */
public enum EnumAction {
LEFT_CLICK,
LEFT_CLICK_SNEAKING,
LEFT_CLICK_SPRINTING,

RIGHT_CLICK,
RIGHT_CLICK_SNEAKING,
RIGHT_CLICK_SPRINTING,
;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.pepedevs.corelib.item;

import com.google.common.base.Objects;
import com.pepedevs.corelib.utils.StringUtils;
import com.pepedevs.corelib.utils.itemstack.ItemMetaBuilder;
import com.pepedevs.corelib.utils.itemstack.ItemStackUtils;
import org.bukkit.Material;
import org.bukkit.event.EventPriority;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/** Abstract class to be used for creating Action Items. */
public abstract class ActionItemBase implements ActionItem {

protected final String display_name;
protected final List<String> lore;
protected final Material material;
protected final EventPriority priority;

/**
* Constructs the Action Item.
*
* <p>
*
* @param display_name Display name of the Action Item
* @param lore Lore of the Action Item
* @param material Material of the Action Item
* @param priority {@link EventPriority} of the Action Item
*/
public ActionItemBase(
String display_name,
Collection<String> lore,
Material material,
EventPriority priority) {
this.display_name = StringUtils.translateAlternateColorCodes(display_name);
this.lore =
StringUtils.translateAlternateColorCodes(
StringUtils.translateAlternateColorCodes(new ArrayList<>(lore)));
this.material = material;
this.priority = priority;
}

/**
* Constructs the Action Item.
*
* <p>
*
* @param display_name Display name of the Action Item
* @param lore Lore of the Action Item
* @param material Material of the Action Item
*/
public ActionItemBase(String display_name, Collection<String> lore, Material material) {
this(display_name, lore, material, EventPriority.NORMAL);
}

@Override
public String getDisplayName() {
return display_name;
}

@Override
public List<String> getLore() {
return lore;
}

@Override
public Material getMaterial() {
return material;
}

@Override
public EventPriority getPriority() {
return priority;
}

@Override
public ItemStack toItemStack() {
return new ItemMetaBuilder(getMaterial())
.withDisplayName(getDisplayName())
.withLore(getLore())
.toItemStack();
}

@Override
public boolean isThis(ItemStack item) {
if (item != null) {
return item.getType() == getMaterial()
&& Objects.equal(ItemStackUtils.extractName(item, false), getDisplayName())
&& Objects.equal(ItemStackUtils.extractLore(item, false), getLore());
} else {
return false;
}
}
}
Loading

0 comments on commit 0fb4d7b

Please sign in to comment.