diff --git a/README.md b/README.md
index 927016d..2abc965 100644
--- a/README.md
+++ b/README.md
@@ -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.'
@@ -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.
\ No newline at end of file
+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:
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5af5f66..0113949 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,9 +4,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- de.paul2708
- FuseMemory
- 1.0-SNAPSHOT
+ de.paul2708.wlosp
+ memory
+ 0.0.1-SNAPSHOT
+
+
+ 14
+ 14
+ UTF-8
+
+ 1.16.1-R0.1-SNAPSHOT
+
@@ -16,33 +24,21 @@
-
org.spigotmc
spigot-api
- 1.8.8-R0.1-SNAPSHOT
+ ${spigot.version}
provided
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.2
-
-
- 1.8
-
-
-
-
+
org.apache.maven.plugins
maven-shade-plugin
- 2.3
+ 3.2.2
package
@@ -51,11 +47,34 @@
false
+ memory
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.0
+
+
+ com.puppycrawl.tools
+ checkstyle
+ 8.14
+
+
+
+
+ validate
+ none
+
+
+
+ src/test/resources/checkstyle.xml
+ false
+
+
-
\ No newline at end of file
diff --git a/src/main/java/de/paul2708/memory/file/ConfigFile.java b/src/main/java/de/paul2708/memory/file/ConfigFile.java
index 5faea44..dae4be1 100644
--- a/src/main/java/de/paul2708/memory/file/ConfigFile.java
+++ b/src/main/java/de/paul2708/memory/file/ConfigFile.java
@@ -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;
@@ -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);
@@ -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");
}
}
diff --git a/src/main/java/de/paul2708/memory/game/GameManager.java b/src/main/java/de/paul2708/memory/game/GameManager.java
index b92ed9a..a74ea5e 100644
--- a/src/main/java/de/paul2708/memory/game/GameManager.java
+++ b/src/main/java/de/paul2708/memory/game/GameManager.java
@@ -23,7 +23,6 @@ public class GameManager {
private boolean joinPerBlock;
private Material material;
- private byte subId;
public GameManager() {
this.games = new ArrayList<>();
@@ -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());
@@ -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;
}
}
@@ -82,8 +74,4 @@ public boolean canJoinPerBlock() {
public Material getMaterial() {
return material;
}
-
- public byte getSubId() {
- return subId;
- }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/de/paul2708/memory/listener/InventoryClickListener.java b/src/main/java/de/paul2708/memory/listener/InventoryClickListener.java
index 01c05d5..7972ccb 100644
--- a/src/main/java/de/paul2708/memory/listener/InventoryClickListener.java
+++ b/src/main/java/de/paul2708/memory/listener/InventoryClickListener.java
@@ -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) {
diff --git a/src/main/java/de/paul2708/memory/listener/PlayerInteractListener.java b/src/main/java/de/paul2708/memory/listener/PlayerInteractListener.java
index 0c1c86b..71aaad6 100644
--- a/src/main/java/de/paul2708/memory/listener/PlayerInteractListener.java
+++ b/src/main/java/de/paul2708/memory/listener/PlayerInteractListener.java
@@ -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();
diff --git a/src/main/java/de/paul2708/memory/theme/ClassicTheme.java b/src/main/java/de/paul2708/memory/theme/ClassicTheme.java
index 592badc..579c37c 100644
--- a/src/main/java/de/paul2708/memory/theme/ClassicTheme.java
+++ b/src/main/java/de/paul2708/memory/theme/ClassicTheme.java
@@ -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(),
};
}
diff --git a/src/main/java/de/paul2708/memory/theme/FoodTheme.java b/src/main/java/de/paul2708/memory/theme/FoodTheme.java
index 511d3cd..31c9a74 100644
--- a/src/main/java/de/paul2708/memory/theme/FoodTheme.java
+++ b/src/main/java/de/paul2708/memory/theme/FoodTheme.java
@@ -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(),
};
}
}
diff --git a/src/main/java/de/paul2708/memory/util/Constants.java b/src/main/java/de/paul2708/memory/util/Constants.java
index 600cda8..325a5cd 100644
--- a/src/main/java/de/paul2708/memory/util/Constants.java
+++ b/src/main/java/de/paul2708/memory/util/Constants.java
@@ -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();
}
diff --git a/src/main/java/de/paul2708/memory/util/ItemBuilder.java b/src/main/java/de/paul2708/memory/util/ItemBuilder.java
index c87730c..5a298b9 100644
--- a/src/main/java/de/paul2708/memory/util/ItemBuilder.java
+++ b/src/main/java/de/paul2708/memory/util/ItemBuilder.java
@@ -18,20 +18,18 @@ public class ItemBuilder {
private String name;
private int amount;
private Material type;
- private int subID;
private List description;
private HashMap 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);
@@ -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;
- }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/de/paul2708/memory/util/Util.java b/src/main/java/de/paul2708/memory/util/Util.java
index bd8d577..ee037c4 100644
--- a/src/main/java/de/paul2708/memory/util/Util.java
+++ b/src/main/java/de/paul2708/memory/util/Util.java
@@ -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);
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index f7947ea..dcaec4d 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -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:
diff --git a/src/test/resources/checkstyle.xml b/src/test/resources/checkstyle.xml
new file mode 100644
index 0000000..8c26db0
--- /dev/null
+++ b/src/test/resources/checkstyle.xml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+