Skip to content

Commit

Permalink
Merge pull request #1 from WeLoveOpenSourcePlugins/development
Browse files Browse the repository at this point in the history
Update to 1.16
  • Loading branch information
Paul2708 authored Nov 6, 2020
2 parents f9c9e4a + b7691ee commit 7e6be15
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 103 deletions.
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
# Memory Plugin for Minecraft
--------------------------------------------------
You have a boring serverlobby or just want to play memory in minecraft?
Try our version of memory in minecraft,
because our plugin brings variety in your serverlobby.

## Features
* unique minigame
* awesome gui with beautiful animations
* easy to configure
* works out of the box
* varying themes

## Setup
* Put the [`Memory.jar`](https://www.spigotmc.org/resources/45082/download?version=176527) in your plugin folder
* Start the server and wait until the message file was created
* Put the [`memory.jar`](https://github.com/WeLoveOpenSourcePlugins/memory/releases/latest) in your plugin folder
* Start the server and wait until the message file got created
* Customize the messages (messages.yml)
* Start you're server again and connect
* Start your server again and connect

## How to play
Right-click the customized block (default: noteblock) to join the queue or use /memory. If a second player joins the queue, the game will start.
Leave the game by closing the inventory.

## Configuration
##### config.yml
----------------
```

```yaml
join_per_block: false
join_block_id: '25:0'
join_block: 'NOTE_BLOCK'
```
##### messages.yml
----------------
```
```yaml
tag: '&8[&eMemory&8]'
game:
against: '%tag% &7You are playing against &e%player%&7.'
Expand All @@ -45,11 +48,18 @@ result:
draw: '%tag% &eDraw! - Nobody won.'
win: '%tag% &e%player% has won the game. (%score% pairs)'
```
## Pictures
[![YouTube Gameplay](https://img.youtube.com/vi/-aDJW23rj88/0.jpg)](http://www.youtube.com/watch?v=-aDJW23rj88)
![Queue](https://image.prntscr.com/image/NN0lUvmUTcyjvZx91S-WYw.png)
![GUI](https://image.prntscr.com/image/EUy4z29UT0GKME8PcWXpYQ.png)
-----------------------------
## Problems during installation?
Just write a PM to [@Paul2708](https://www.spigotmc.org/members/paul2708.44827/) on Spigot or contact me via Twitter ([@theplayerpaul](https://twitter.com/theplayerpaul)), Discord or Skype.
Thank you for your attention.
Just write a PM to [@Paul2708](https://www.spigotmc.org/members/paul2708.44827/) on Spigot or contact me via Twitter ([@theplayerpaul](https://twitter.com/theplayerpaul)) or Discord (Paul2708#1098).
Thank you for your attention.
## Contribute
If you find any bugs or want to contribute, just open an issue! We would appreciate it.
> WeLoveOpenSourcePlugins :heart:
57 changes: 38 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.paul2708</groupId>
<artifactId>FuseMemory</artifactId>
<version>1.0-SNAPSHOT</version>
<groupId>de.paul2708.wlosp</groupId>
<artifactId>memory</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
<maven.compiler.target>14</maven.compiler.target>
<maven.compiler.source>14</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
</properties>

<repositories>
<repository>
Expand All @@ -16,33 +24,21 @@
</repositories>

<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

<!-- Shade JAR -->
<!-- Shade -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<version>3.2.2</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -51,11 +47,34 @@
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<finalName>memory</finalName>
</configuration>
</execution>
</executions>
</plugin>
<!-- Checkstyle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.14</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<configLocation>src/test/resources/checkstyle.xml</configLocation>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
</plugins>
</build>

</project>
7 changes: 4 additions & 3 deletions src/main/java/de/paul2708/memory/file/ConfigFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.paul2708.memory.Memory;
import de.paul2708.memory.util.Constants;
import org.bukkit.Material;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
Expand Down Expand Up @@ -54,7 +55,7 @@ public void load() {

private void createDefaultValues() {
configuration.set("join_per_block", true);
configuration.set("join_block_id", "25:0");
configuration.set("join_block", Material.NOTE_BLOCK.toString().toUpperCase());

try {
configuration.save(configFile);
Expand All @@ -67,7 +68,7 @@ public boolean canJoinPerBlock() {
return configuration.getBoolean("join_per_block");
}

public String getBlockId() {
return configuration.getString("join_block_id");
public String getMaterialType() {
return configuration.getString("join_block");
}
}
22 changes: 5 additions & 17 deletions src/main/java/de/paul2708/memory/game/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class GameManager {

private boolean joinPerBlock;
private Material material;
private byte subId;

public GameManager() {
this.games = new ArrayList<>();
Expand All @@ -32,14 +31,7 @@ public GameManager() {
this.queue = new Queue();

this.joinPerBlock = Memory.getConfigFile().canJoinPerBlock();
String sId = Memory.getConfigFile().getBlockId();
if (sId.contains(":")) {
this.material = Material.getMaterial(Integer.valueOf(sId.split(":")[0]));
this.subId = Byte.valueOf(sId.split(":")[1]);
} else {
this.material = Material.getMaterial(Integer.valueOf(sId));
this.subId = (byte) 0;
}
this.material = Material.valueOf(Memory.getConfigFile().getMaterialType());

// Themes
themes.add(new ClassicTheme());
Expand All @@ -51,9 +43,9 @@ public Theme getRandomTheme() {
}

public Game getGame(Player p) {
for(Game all : games) {
for(Player gPlayer : all.getPlayers()) {
if(gPlayer.getName().equals(p.getName())) {
for (Game all : games) {
for (Player gPlayer : all.getPlayers()) {
if (gPlayer.getName().equals(p.getName())) {
return all;
}
}
Expand Down Expand Up @@ -82,8 +74,4 @@ public boolean canJoinPerBlock() {
public Material getMaterial() {
return material;
}

public byte getSubId() {
return subId;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public void onClick(InventoryClickEvent e) {
if (game != null) {
e.setCancelled(true);

if (e.getClickedInventory() == null || e.getClickedInventory().getTitle() == null ||
!e.getClickedInventory().getTitle().contains(player.getName())) {
if (e.getClickedInventory() == null || !e.getView().getTitle().contains(player.getName())) {
return;
}
if (e.getAction() == InventoryAction.PICKUP_ALL || e.getAction() == InventoryAction.PICKUP_HALF) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public void onInteract(PlayerInteractEvent e) {
if (!Memory.getGameManager().canJoinPerBlock()) {
return;
}
if (block.getType() == Memory.getGameManager().getMaterial() &&
block.getData() == Memory.getGameManager().getSubId()) {
if (block.getType() == Memory.getGameManager().getMaterial()) {
e.setCancelled(true);

Queue queue = Memory.getGameManager().getQueue();
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/de/paul2708/memory/theme/ClassicTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public ItemStack[] getPairs() {
new ItemBuilder().name("Zucker").type(Material.SUGAR).getItem(),
};*/
return new ItemStack[] {
new ItemBuilder().id(351).subID(13).getItem(),
new ItemBuilder().id(351).subID(8).getItem(),
new ItemBuilder().id(351).subID(1).getItem(),
new ItemBuilder().type(Material.SULPHUR).getItem(),
new ItemBuilder().type(Material.MAGENTA_DYE).getItem(),
new ItemBuilder().type(Material.GRAY_DYE).getItem(),
new ItemBuilder().type(Material.RED_DYE).getItem(),
new ItemBuilder().type(Material.GUNPOWDER).getItem(),
new ItemBuilder().type(Material.GLOWSTONE_DUST).getItem(),
new ItemBuilder().id(351).subID(2).getItem(),
new ItemBuilder().type(Material.GREEN_DYE).getItem(),
new ItemBuilder().type(Material.FLINT).getItem(),
new ItemBuilder().id(351).subID(10).getItem(),
new ItemBuilder().id(351).subID(12).getItem(),
new ItemBuilder().id(351).subID(14).getItem(),
new ItemBuilder().id(351).subID(9).getItem(),
new ItemBuilder().id(351).subID(5).getItem(),
new ItemBuilder().id(351).subID(4).getItem(),
new ItemBuilder().type(Material.LIME_DYE).getItem(),
new ItemBuilder().type(Material.LIGHT_BLUE_DYE).getItem(),
new ItemBuilder().type(Material.ORANGE_DYE).getItem(),
new ItemBuilder().type(Material.PINK_DYE).getItem(),
new ItemBuilder().type(Material.PURPLE_DYE).getItem(),
new ItemBuilder().type(Material.LAPIS_LAZULI).getItem(),
new ItemBuilder().type(Material.SUGAR).getItem(),
};
}
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/de/paul2708/memory/theme/FoodTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ public ItemStack[] getPairs() {
new ItemBuilder().name("Roher Kabeljau").type(Material.RAW_FISH).getItem(),
};*/
return new ItemStack[] {
new ItemBuilder().id(297).getItem(),
new ItemBuilder().id(412).getItem(),
new ItemBuilder().id(392).getItem(),
new ItemBuilder().type(Material.BREAD).getItem(),
new ItemBuilder().type(Material.COOKED_RABBIT).getItem(),
new ItemBuilder().type(Material.POTATO).getItem(),
new ItemBuilder().type(Material.COOKED_BEEF).getItem(),
new ItemBuilder().id(391).getItem(),
new ItemBuilder().id(354).getItem(),
new ItemBuilder().id(349).subID(2).getItem(),
new ItemBuilder().id(260).getItem(),
new ItemBuilder().id(424).getItem(),
new ItemBuilder().id(393).getItem(),
new ItemBuilder().id(320).getItem(),
new ItemBuilder().id(357).getItem(),
new ItemBuilder().id(349).subID(3).getItem(),
new ItemBuilder().type(Material.RAW_FISH).getItem(),
new ItemBuilder().type(Material.CARROT).getItem(),
new ItemBuilder().type(Material.CAKE).getItem(),
new ItemBuilder().type(Material.TROPICAL_FISH).getItem(),
new ItemBuilder().type(Material.APPLE).getItem(),
new ItemBuilder().type(Material.COOKED_MUTTON).getItem(),
new ItemBuilder().type(Material.BAKED_POTATO).getItem(),
new ItemBuilder().type(Material.COOKED_PORKCHOP).getItem(),
new ItemBuilder().type(Material.COOKIE).getItem(),
new ItemBuilder().type(Material.PUFFERFISH).getItem(),
new ItemBuilder().type(Material.ENCHANTED_GOLDEN_APPLE).getItem(),
};
}
}
4 changes: 2 additions & 2 deletions src/main/java/de/paul2708/memory/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class Constants {

public static final String TAG = "§8[§eMemory§8] §7";

public static final ItemStack COVER = new ItemBuilder().name("?").type(Material.STAINED_GLASS_PANE).subID(0).getItem();
public static final ItemStack BORDER = new ItemBuilder().name("").type(Material.STAINED_GLASS_PANE).subID(15).getItem();
public static final ItemStack COVER = new ItemBuilder().name("?").type(Material.WHITE_STAINED_GLASS_PANE).getItem();
public static final ItemStack BORDER = new ItemBuilder().name("").type(Material.BLACK_STAINED_GLASS_PANE).getItem();
}
17 changes: 2 additions & 15 deletions src/main/java/de/paul2708/memory/util/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@ public class ItemBuilder {
private String name;
private int amount;
private Material type;
private int subID;
private List<String> description;
private HashMap<Enchantment, Integer> enchantments;

public ItemBuilder() {
this.amount = 1;
this.subID = 0;
this.description = new ArrayList<>();
this.enchantments = new HashMap<>();
}

@SuppressWarnings("deprecation")
public ItemStack getItem() {
ItemStack item = new ItemStack(type.getId(), amount, (short) subID);
ItemStack item = new ItemStack(type, amount);
ItemMeta meta = item.getItemMeta();
if(name != null) meta.setDisplayName(name);
if(description.size() != 0) meta.setLore(description);
Expand Down Expand Up @@ -71,15 +69,4 @@ public ItemBuilder type(Material type) {
this.type = type;
return this;
}

@SuppressWarnings("deprecation")
public ItemBuilder id(int id) {
this.type = Material.getMaterial(id);
return this;
}

public ItemBuilder subID(int subID) {
this.subID = subID;
return this;
}
}
}
8 changes: 1 addition & 7 deletions src/main/java/de/paul2708/memory/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ public class Util {
public static final Random random = new Random();

public static boolean isSame(ItemStack item, ItemStack copy) {
if (item.getType() == copy.getType()) {
if (item.getDurability() == copy.getDurability()) {
return true;
}
}

return false;
return item != null && item.isSimilar(copy);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Memory
version: 1.1
version: 1.2.0
author: Paul2708
api-version: 1.16

main: de.paul2708.memory.Memory
commands:
Expand Down
Loading

0 comments on commit 7e6be15

Please sign in to comment.