Skip to content

Commit

Permalink
Merge pull request #44 from m7rlin/dev/marcin
Browse files Browse the repository at this point in the history
(chore) release 1.4.1
  • Loading branch information
m7rlin committed Jun 10, 2023
2 parents 0636c6a + 141a7ab commit 0e092d7
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>pl.mgtm</groupId>
<artifactId>MagicznaKraina</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<packaging>jar</packaging>

<name>MagicznaKraina</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ default String getApiUrl() {
*/

default SerduszkoModuleConfig getSerduszkoModule() {
return new SerduszkoModuleConfig(true, true);
return new SerduszkoModuleConfig(true, true, 10.0, 40.0, true);
}

void setSerduszkoModule(SerduszkoModuleConfig serduszkoModuleConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class SerduszkoModuleConfig implements Serializable {
// Can players be revived
private boolean playerReviveEnabled;
// Default hearts when new user joined the server
private double defaultHearts = 6.0;
private double defaultHearts;
// Max hearts player can get
private double heartsLimit = 40.0;
private double heartsLimit;
// When player hearts reach 0 HP he will be banned.
private boolean banOnZeroHearts = true;
// Items required for revive. The items will be taken away.
Expand All @@ -26,15 +26,19 @@ public class SerduszkoModuleConfig implements Serializable {
// Revive level
private int reviveLevel = 30;
//
private Integer[] levels = { 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 22, 24, 26, 27, 28, 29, 30, 31, 33, 35, 36, 37, 38, 39, 40 };
private Integer[] levels = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 22, 24, 26, 27, 28, 29, 30, 31, 33, 35, 36, 37, 38, 39, 40};

public SerduszkoModuleConfig() {
}

public SerduszkoModuleConfig(boolean moduleEnabled, boolean playerReviveEnabled) {
public SerduszkoModuleConfig(boolean moduleEnabled, boolean playerReviveEnabled, double defaultHearts, double heartsLimit, boolean banOnZeroHearts) {
this.enabled = moduleEnabled;
this.playerReviveEnabled = playerReviveEnabled;

this.setHeartsLimit(heartsLimit);
this.setDefaultHearts(defaultHearts);
this.setBanOnZeroHearts(banOnZeroHearts);

List<ItemStack> reviveItems = new ArrayList<>();
reviveItems.add(new ItemStack(Material.DIAMOND, 64));
reviveItems.add(new ItemStack(Material.GOLD_INGOT, 32));
Expand Down Expand Up @@ -88,4 +92,12 @@ public void addReviveItem(ItemStack item) {
public Integer[] getLevels() {
return levels;
}

public boolean getBanOnZeroHearts() {
return banOnZeroHearts;
}

public void setBanOnZeroHearts(boolean status) {
banOnZeroHearts = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|| event.getDamager().getType().equals(EntityType.SPIDER)) {

// Blast the player into the air
if (random.nextInt(1) == 0) { // 10% chance
if (random.nextInt(4) == 0) { // 25% chance
//player.sendMessage("To the air!");

// Only works when player is jumping
Expand All @@ -47,7 +47,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
player.setVelocity(player.getVelocity().add(new Vector(0, 1, 0)));
}
// Take away player's weapon
if (random.nextInt(2) == 0) { // 1% chance
if (random.nextInt(50) == 0) { // 2% chance
// Remove player hand item
//player.getInventory().setItemInMainHand(null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();

// Check if the broken block is Stone
if (block.getType() == Material.STONE) {
if (block.getType() == Material.STONE || block.getType() == Material.DEEPSLATE) {
// Get the Y-coordinate of the broken block
int blockY = block.getLocation().getBlockY();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public void onPlayerJoinServer(PlayerJoinEvent event) {

// Add new user to config
if (users.get(uuid) == null) {
users.put(uuid, new User(player.getName()));
User user = new User(player.getName());
user.setHearts(pl.getMainConfig().getSerduszkoModule().getDefaultHearts());
users.put(uuid, user);
pl.getUserConfig().setUsers(users);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class PreLoginEvent implements Listener {
public void onPlayerJoinServer(PlayerLoginEvent event) {
Player player = event.getPlayer();

if (pl.getUserConfig().getUsers() == null) {
event.allow();
return;
}

User user = pl.getUserConfig().getUsers().get(player.getUniqueId().toString());
if (user == null) {
event.allow();
Expand Down

0 comments on commit 0e092d7

Please sign in to comment.