Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit 0ec38b7

Browse files
committed
2.9.6
1 parent dcd413d commit 0ec38b7

15 files changed

Lines changed: 344 additions & 201 deletions

File tree

.idea/libraries/Maven__com_destroystokyo_paper_paper_api_1_13_2_R0_1_SNAPSHOT.xml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 182 additions & 158 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PickupSpawners.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</content>
2222
<orderEntry type="inheritedJdk" />
2323
<orderEntry type="sourceFolder" forTests="false" />
24-
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.14-R0.1-SNAPSHOT" level="project" />
24+
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.14.1-R0.1-SNAPSHOT" level="project" />
2525
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
2626
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
2727
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />

dependency-reduced-pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>me.poma123</groupId>
55
<artifactId>pickupspawners</artifactId>
66
<name>PickupSpawners</name>
7-
<version>2.9.4</version>
7+
<version>2.9.6</version>
88
<build>
99
<defaultGoal>clean package</defaultGoal>
1010
<resources>
@@ -58,7 +58,7 @@
5858
<dependency>
5959
<groupId>org.spigotmc</groupId>
6060
<artifactId>spigot-api</artifactId>
61-
<version>1.14-R0.1-SNAPSHOT</version>
61+
<version>1.14.1-R0.1-SNAPSHOT</version>
6262
<scope>provided</scope>
6363
<exclusions>
6464
<exclusion>

pom.xml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>me.poma123</groupId>
66
<artifactId>pickupspawners</artifactId>
7-
<version>2.9.4</version>
7+
<version>2.9.6</version>
88
<packaging>jar</packaging>
99

1010
<name>PickupSpawners</name>
@@ -25,22 +25,6 @@
2525
<target>1.8</target>
2626
</configuration>
2727
</plugin>
28-
<plugin>
29-
<groupId>org.apache.maven.plugins</groupId>
30-
<artifactId>maven-shade-plugin</artifactId>
31-
<version>3.1.0</version>
32-
<executions>
33-
<execution>
34-
<phase>package</phase>
35-
<goals>
36-
<goal>shade</goal>
37-
</goals>
38-
<configuration>
39-
<minimizeJar>true</minimizeJar>
40-
</configuration>
41-
</execution>
42-
</executions>
43-
</plugin>
4428
</plugins>
4529
<resources>
4630
<resource>
@@ -73,7 +57,7 @@
7357
<dependency>
7458
<groupId>org.spigotmc</groupId>
7559
<artifactId>spigot-api</artifactId>
76-
<version>1.14-R0.1-SNAPSHOT</version>
60+
<version>1.14.1-R0.1-SNAPSHOT</version>
7761
<scope>provided</scope>
7862
</dependency>
7963

src/main/java/me/poma123/spawners/Listener.java

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,24 @@
4343
import org.bukkit.event.EventHandler;
4444
import org.bukkit.event.EventPriority;
4545
import org.bukkit.event.block.BlockBreakEvent;
46+
import org.bukkit.event.block.BlockExplodeEvent;
4647
import org.bukkit.event.block.BlockPlaceEvent;
4748
import org.bukkit.event.block.SignChangeEvent;
49+
import org.bukkit.event.entity.EntityExplodeEvent;
4850
import org.bukkit.event.inventory.InventoryClickEvent;
4951
import org.bukkit.event.player.PlayerInteractEvent;
5052
import org.bukkit.event.player.PlayerJoinEvent;
5153
import org.bukkit.inventory.Inventory;
5254
import org.bukkit.inventory.ItemStack;
55+
import org.bukkit.inventory.meta.Damageable;
5356
import org.bukkit.inventory.meta.ItemMeta;
5457
import org.bukkit.plugin.Plugin;
5558

5659
import java.io.File;
5760
import java.io.IOException;
5861
import java.time.LocalDate;
5962
import java.time.ZoneId;
60-
import java.util.ArrayList;
61-
import java.util.Date;
62-
import java.util.List;
63+
import java.util.*;
6364
import java.util.regex.Pattern;
6465

6566
public class Listener implements org.bukkit.event.Listener {
@@ -310,20 +311,73 @@ public void onOpJoin(PlayerJoinEvent e) {
310311
}
311312
}
312313

314+
315+
316+
317+
public static <K, V extends Comparable<V>> NavigableMap<K, V> sortByValues(final Map<K, V> map) {
318+
final Comparator<K> valueComparator = new Comparator<K>() {
319+
@Override
320+
public int compare(final K k1, final K k2) {
321+
final int compare = map.get(k2).compareTo(map.get(k1));
322+
if (compare == 0) {
323+
return 1;
324+
}
325+
return compare;
326+
}
327+
};
328+
final NavigableMap<K, V> sortedByValues = new TreeMap<K, V>(valueComparator);
329+
sortedByValues.putAll((Map<? extends K, ? extends V>)map);
330+
return sortedByValues;
331+
}
332+
313333
private boolean isLimitBlocks(Player p) {
314334
if (p.hasPermission("spawnerlimit.bypass")) {
315335
return false;
316336
}
337+
String limitPermissionPrefix = "pickupspawners.breaklimit.";
317338
Date date = new Date();
318339
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
319340
int year = localDate.getYear();
320341
int month = localDate.getMonthValue();
321342
int day = localDate.getDayOfMonth();
322-
Object limit = sett.getConfig().get("daily-broke-limit");
343+
344+
// List<String> limits = new ArrayList<>();
345+
NavigableMap<String, Integer> map = new TreeMap<>();
346+
347+
for (String str : sett.getConfig().getConfigurationSection("break-limits").getKeys(false)) {
348+
// limits.add(str + ";" + sett.getConfig().get("break-limits." + str));
349+
//TODO DEBUG plugin.getLogger().info(str +": " + sett.getConfig().getInt("break-limits." + str));
350+
if (str.equals("default")) {
351+
// plugin.getLogger().info("VANJOG: "+ limitPermissionPrefix + str);
352+
map.put(limitPermissionPrefix+str, sett.getConfig().getInt("break-limits." + str));
353+
} else if (p.hasPermission(limitPermissionPrefix + str)) {
354+
// plugin.getLogger().info("VANJOG: "+ limitPermissionPrefix + str);
355+
map.put(limitPermissionPrefix+str, sett.getConfig().getInt("break-limits." + str));
356+
}
357+
}
358+
359+
/* for (String str : limits) {
360+
String path = str.split(";")[0];
361+
int value = Integer.valueOf(str.split(";")[1]);
362+
if (p.hasPermission(limitPermissionPrefix + path)) {
363+
map.put(limitPermissionPrefix+path, value);
364+
}
365+
}*/
366+
367+
NavigableMap<String, Integer> sorted = sortByValues(map);
368+
369+
Map.Entry<String, Integer> lastEntry = sorted.firstEntry();
370+
int limit = lastEntry.getValue();
371+
// System.out.println("LIMIT: " + limit);
372+
//Object limit = sett.getConfig().get("daily-broke-limit");
373+
374+
375+
376+
323377
int limit1 = 0;
324378
try {
325379

326-
limit1 = (int) limit;
380+
limit1 = limit;
327381

328382
} catch (Exception e) {
329383
System.out.println(
@@ -374,13 +428,21 @@ private boolean isLimitBlocks(Player p) {
374428

375429

376430
public boolean isItemStacksGood(ItemStack saved, ItemStack used, String path) {
431+
if (used == null) {
432+
System.out.println("§c[PickupSpawners] The spawner breaker item (used) is null. Please create an issue with the following stacktrace on github.com/poma123/PickupSpawners");
433+
434+
}
435+
if (saved == null) {
436+
System.out.println("§c[PickupSpawners] The spawner breaker item (saved) is null. Please create an issue with the following stacktrace on github.com/poma123/PickupSpawners");
437+
}
377438
if (used.hasItemMeta() && saved.hasItemMeta()) {
378439
ItemMeta savedM = saved.getItemMeta();
379440
ItemMeta usedM = used.getItemMeta();
380441
boolean disp = true;
381442
boolean lore = true;
382443
boolean enchants = true;
383444
boolean material = true;
445+
boolean damage = true;
384446
if (used.getType().equals(saved.getType())) {
385447
material = true;
386448
} else {
@@ -409,6 +471,19 @@ public boolean isItemStacksGood(ItemStack saved, ItemStack used, String path) {
409471
}
410472
}
411473

474+
if (PickupSpawners.getVersion().contains("1_13_") || PickupSpawners.getVersion().contains("1_14_") || PickupSpawners.getVersion().contains("1_15_")) {
475+
if (savedM instanceof Damageable && ((Damageable) savedM).hasDamage()) {
476+
if (usedM instanceof Damageable && ((Damageable) usedM).hasDamage()) {
477+
if (((Damageable) usedM).getDamage() == ((Damageable) savedM).getDamage()) {
478+
damage = true;
479+
} else {
480+
damage = false;
481+
}
482+
} else {
483+
damage = false;
484+
}
485+
}
486+
}
412487
if ( savedM.hasEnchants()) {
413488
if (!usedM.hasEnchants()) {
414489
enchants = false;
@@ -449,7 +524,7 @@ public boolean isItemStacksGood(ItemStack saved, ItemStack used, String path) {
449524
}
450525
}
451526

452-
if (disp && lore && enchants && material) {
527+
if (disp && lore && enchants && material && damage) {
453528
return true;
454529
}
455530

@@ -461,7 +536,8 @@ public boolean isItemStacksGood(ItemStack saved, ItemStack used, String path) {
461536
}
462537
return false;
463538
}
464-
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
539+
540+
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
465541
public void onSpawnerBreak(BlockBreakEvent e) {
466542
Block s = e.getBlock();
467543
String lang = getLang(e.getPlayer());
@@ -488,6 +564,9 @@ public void onSpawnerBreak(BlockBreakEvent e) {
488564

489565
boolean isGoodItem = false;
490566

567+
if (item == null) {
568+
return;
569+
}
491570
for (String string : sett.getConfig().getConfigurationSection("item").getKeys(false)) {
492571
ItemStack breakerItem = (ItemStack) sett.getConfig().get("item." + string + ".itemstack");
493572

@@ -637,6 +716,11 @@ public void onSpawnerBreak(BlockBreakEvent e) {
637716
}
638717
}
639718

719+
public boolean compareTwoList(List<String> models, String str) {
720+
return Arrays.asList(str).stream().allMatch(t -> models.stream().anyMatch(t::contains));
721+
}
722+
723+
640724
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
641725
public void onSpawnerPlace(BlockPlaceEvent event) {
642726
Block block = event.getBlockPlaced();

src/main/java/me/poma123/spawners/PSCommand.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.bukkit.entity.EntityType;
3434
import org.bukkit.entity.Player;
3535
import org.bukkit.inventory.ItemStack;
36+
import org.bukkit.inventory.meta.Damageable;
3637
import org.bukkit.inventory.meta.ItemMeta;
3738

3839
import java.util.*;
@@ -359,6 +360,8 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
359360
}
360361

361362

363+
364+
362365
// Material mat = itemstack.getType();
363366

364367

@@ -372,6 +375,16 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
372375

373376
sett.getConfig().set("item." + random + ".enchants", enchants);
374377
}
378+
379+
380+
if (itemstack.hasItemMeta() && itemstack.getItemMeta() instanceof Damageable) {
381+
Damageable dm = (Damageable) itemstack.getItemMeta();
382+
if (dm.hasDamage()) {
383+
sett.getConfig().set("item." + random + ".damage", dm.getDamage());
384+
}
385+
}
386+
387+
375388
sett.getConfig().set("item." + random + ".itemstack", itemstack);
376389
/* sett.getConfig().set("item." + random + ".material", output.getType().toString());
377390
sett.getConfig().set("item." + random + ".data", data);*/

src/main/java/me/poma123/spawners/PickupSpawners.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static PickupSpawners getInstance() {
5656
}
5757

5858
public static String generateRandomString(int length) {
59-
6059
boolean useLetters = true;
6160
boolean useNumbers = true;
6261
String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
@@ -104,7 +103,6 @@ public void onEnable() {
104103
Language.saveLocales();
105104

106105
/*
107-
108106
* Just why not?
109107
*/
110108
getLogger().info("-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-");
@@ -252,6 +250,33 @@ public void onEnable() {
252250
saveDefaultConfig();
253251
s.setup(PickupSpawners.getPlugin(PickupSpawners.class));
254252

253+
254+
255+
/*
256+
* Setting new configuration sections
257+
*/
258+
259+
260+
if (getConfig().get("break-limits") == null) {
261+
262+
if (getConfig().get("daily-broke-limit") != null) {
263+
getConfig().set("break-limits.default", getConfig().getInt("daily-broke-limit"));
264+
} else {
265+
getConfig().set("break-limits.default", 0);
266+
}
267+
268+
saveConfig();
269+
270+
}
271+
/* if (s.getConfig().get("break-on-explosions") == null) {
272+
s.getConfig().set("break-on-explosions.enabled", false);
273+
s.getConfig().set("break-on-explosions.chance", 50);
274+
s.saveConfig();
275+
}*/
276+
277+
278+
279+
255280
/*
256281
* Setting the default spawner breaker item if the list is empty
257282
*/

src/main/java/me/poma123/spawners/gui/PickupGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public void spawnerGiveList(Player p, int page) {
316316

317317
public ItemStack getSpawnegg(String type) {
318318

319-
if (ps.isOnePointThirteen) {
319+
if (ps.isOnePointThirteen || ps.isOnePointFourteen) {
320320
if (type.equalsIgnoreCase("PIG_ZOMBIE")) {
321321
return new ItemStack(Material.ZOMBIE_PIGMAN_SPAWN_EGG, 1);
322322
} else {

src/main/resources/config.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
# Daily break limit is now actually counts when the server is online. Once the server restarted it will be reset. I'll create a better solution for this.
1+
# Daily break limit now counts daily.
2+
# The default's permission is pickupspawners.breaklimit.default, and is true for everyone.
3+
# You can add here more limits. The 'vip' named limit's permission is pickupspawners.breaklimit.vip
24
# Set 0 to disable
3-
daily-broke-limit: 5
5+
break-limits:
6+
default: 0
7+
# vip: 10
48

59
# Checks new version and prints to the console and to OP's when they join.
610
# Set false to disable.
711
update-check: true
812

9-
# It depends on the language of the player's client. Currently only English and Hungarian languages supported.
13+
# It depends on the language of the player's client. Currently, only English and Hungarian languages are supported.
1014
# If you want to add your language, just create a [PR](https://github.com/poma123/PickupSpawners/pulls)!
1115
# Set false to disable
1216
auto-locale: true

0 commit comments

Comments
 (0)