Rename and clean up MapleFamilyEntitlement

This commit is contained in:
P0nk
2021-09-09 21:17:31 +02:00
parent 3370152d58
commit 0c8bef6842
5 changed files with 29 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
package client; package client;
public enum MapleFamilyEntitlement { public enum FamilyEntitlement {
FAMILY_REUINION(1, 300, "Family Reunion", "[Target] Me\\n[Effect] Teleport directly to the Family member of your choice."), FAMILY_REUINION(1, 300, "Family Reunion", "[Target] Me\\n[Effect] Teleport directly to the Family member of your choice."),
SUMMON_FAMILY(1, 500, "Summon Family", "[Target] 1 Family member\\n[Effect] Summon a Family member of choice to the map you're in."), SUMMON_FAMILY(1, 500, "Summon Family", "[Target] 1 Family member\\n[Effect] Summon a Family member of choice to the map you're in."),
SELF_DROP_1_5(1, 700, "My Drop Rate 1.5x (15 min)", "[Target] Me\\n[Time] 15 min.\\n[Effect] Monster drop rate will be increased #c1.5x#.\\n* If the Drop Rate event is in progress, this will be nullified."), SELF_DROP_1_5(1, 700, "My Drop Rate 1.5x (15 min)", "[Target] Me\\n[Time] 15 min.\\n[Effect] Monster drop rate will be increased #c1.5x#.\\n* If the Drop Rate event is in progress, this will be nullified."),
@@ -12,29 +12,29 @@ public enum MapleFamilyEntitlement {
SELF_EXP_2_30MIN(1, 2500, "My EXP 2x (30 min)", "[Target] Me\\n[Time] 30 min.\\n[Effect] EXP earned from hunting will be increased #c2x#. \\n* If the EXP event is in progress, this will be nullified."), SELF_EXP_2_30MIN(1, 2500, "My EXP 2x (30 min)", "[Target] Me\\n[Time] 30 min.\\n[Effect] EXP earned from hunting will be increased #c2x#. \\n* If the EXP event is in progress, this will be nullified."),
PARTY_DROP_2_30MIN(1, 4000, "My Party Drop Rate 2x (30 min)", "[Target] My party\\n[Time] 30 min.\\n[Effect] Monster drop rate will be increased #c2x#.\\n* If the Drop Rate event is in progress, this will be nullified."), PARTY_DROP_2_30MIN(1, 4000, "My Party Drop Rate 2x (30 min)", "[Target] My party\\n[Time] 30 min.\\n[Effect] Monster drop rate will be increased #c2x#.\\n* If the Drop Rate event is in progress, this will be nullified."),
PARTY_EXP_2_30MIN(1, 5000, "My Party EXP 2x (30 min)", "[Target] My party\\n[Time] 30 min.\\n[Effect] EXP earned from hunting will be increased #c2x#.\\n* If the EXP event is in progress, this will be nullified."); PARTY_EXP_2_30MIN(1, 5000, "My Party EXP 2x (30 min)", "[Target] My party\\n[Time] 30 min.\\n[Effect] EXP earned from hunting will be increased #c2x#.\\n* If the EXP event is in progress, this will be nullified.");
private final int usageLimit, repCost; private final int usageLimit, repCost;
private final String name, description; private final String name, description;
private MapleFamilyEntitlement(int usageLimit, int repCost, String name, String description) { FamilyEntitlement(int usageLimit, int repCost, String name, String description) {
this.usageLimit = usageLimit; this.usageLimit = usageLimit;
this.repCost = repCost; this.repCost = repCost;
this.name = name; this.name = name;
this.description = description; this.description = description;
} }
public int getUsageLimit() { public int getUsageLimit() {
return usageLimit; return usageLimit;
} }
public int getRepCost() { public int getRepCost() {
return repCost; return repCost;
} }
public String getName() { public String getName() {
return name; return name;
} }
public String getDescription() { public String getDescription() {
return description; return description;
} }

View File

@@ -471,7 +471,7 @@ public class MapleFamilyEntry {
return new Pair<>(highestGeneration, juniorCount); //creating new objects to return is a bit inefficient, but cleaner than packing into a long return new Pair<>(highestGeneration, juniorCount); //creating new objects to return is a bit inefficient, but cleaner than packing into a long
} }
public boolean useEntitlement(MapleFamilyEntitlement entitlement) { public boolean useEntitlement(FamilyEntitlement entitlement) {
int id = entitlement.ordinal(); int id = entitlement.ordinal();
if(entitlements[id] >= 1) return false; if(entitlements[id] >= 1) return false;
try(Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("INSERT INTO family_entitlement (entitlementid, charid, timestamp) VALUES (?, ?, ?)")) { try(Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("INSERT INTO family_entitlement (entitlementid, charid, timestamp) VALUES (?, ?, ?)")) {
@@ -487,7 +487,7 @@ public class MapleFamilyEntry {
return true; return true;
} }
public boolean refundEntitlement(MapleFamilyEntitlement entitlement) { public boolean refundEntitlement(FamilyEntitlement entitlement) {
int id = entitlement.ordinal(); int id = entitlement.ordinal();
try(Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE entitlementid = ? AND charid = ?")) { try(Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE entitlementid = ? AND charid = ?")) {
ps.setInt(1, id); ps.setInt(1, id);
@@ -501,11 +501,11 @@ public class MapleFamilyEntry {
return true; return true;
} }
public boolean isEntitlementUsed(MapleFamilyEntitlement entitlement) { public boolean isEntitlementUsed(FamilyEntitlement entitlement) {
return entitlements[entitlement.ordinal()] >= 1; return entitlements[entitlement.ordinal()] >= 1;
} }
public int getEntitlementUsageCount(MapleFamilyEntitlement entitlement) { public int getEntitlementUsageCount(FamilyEntitlement entitlement) {
return entitlements[entitlement.ordinal()]; return entitlements[entitlement.ordinal()];
} }
@@ -514,7 +514,7 @@ public class MapleFamilyEntry {
} }
public void resetEntitlementUsages() { public void resetEntitlementUsages() {
for(MapleFamilyEntitlement entitlement : MapleFamilyEntitlement.values()) { for(FamilyEntitlement entitlement : FamilyEntitlement.values()) {
entitlements[entitlement.ordinal()] = 0; entitlements[entitlement.ordinal()] = 0;
} }
} }

View File

@@ -2,7 +2,7 @@ package net.server.channel.handlers;
import client.Character; import client.Character;
import client.Client; import client.Client;
import client.MapleFamilyEntitlement; import client.FamilyEntitlement;
import client.MapleFamilyEntry; import client.MapleFamilyEntry;
import config.YamlConfig; import config.YamlConfig;
import net.AbstractPacketHandler; import net.AbstractPacketHandler;
@@ -30,8 +30,8 @@ public class FamilySummonResponseHandler extends AbstractPacketHandler {
if(accept && inviter.getMap() == map) { //cancel if inviter has changed maps if(accept && inviter.getMap() == map) { //cancel if inviter has changed maps
c.getPlayer().changeMap(map, map.getPortal(0)); c.getPlayer().changeMap(map, map.getPortal(0));
} else { } else {
inviterEntry.refundEntitlement(MapleFamilyEntitlement.SUMMON_FAMILY); inviterEntry.refundEntitlement(FamilyEntitlement.SUMMON_FAMILY);
inviterEntry.gainReputation(MapleFamilyEntitlement.SUMMON_FAMILY.getRepCost(), false); //refund rep cost if declined inviterEntry.gainReputation(FamilyEntitlement.SUMMON_FAMILY.getRepCost(), false); //refund rep cost if declined
inviter.sendPacket(PacketCreator.getFamilyInfo(inviterEntry)); inviter.sendPacket(PacketCreator.getFamilyInfo(inviterEntry));
inviter.dropMessage(5, c.getPlayer().getName() + " has denied the summon request."); inviter.dropMessage(5, c.getPlayer().getName() + " has denied the summon request.");
} }

View File

@@ -23,7 +23,7 @@ package net.server.channel.handlers;
import client.Character; import client.Character;
import client.Client; import client.Client;
import client.MapleFamilyEntitlement; import client.FamilyEntitlement;
import client.MapleFamilyEntry; import client.MapleFamilyEntry;
import config.YamlConfig; import config.YamlConfig;
import net.AbstractPacketHandler; import net.AbstractPacketHandler;
@@ -45,7 +45,7 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) { if(!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
return; return;
} }
MapleFamilyEntitlement type = MapleFamilyEntitlement.values()[p.readInt()]; FamilyEntitlement type = FamilyEntitlement.values()[p.readInt()];
int cost = type.getRepCost(); int cost = type.getRepCost();
MapleFamilyEntry entry = c.getPlayer().getFamilyEntry(); MapleFamilyEntry entry = c.getPlayer().getFamilyEntry();
if(entry.getReputation() < cost || entry.isEntitlementUsed(type)) { if(entry.getReputation() < cost || entry.isEntitlementUsed(type)) {
@@ -53,14 +53,14 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
} }
c.sendPacket(PacketCreator.getFamilyInfo(entry)); c.sendPacket(PacketCreator.getFamilyInfo(entry));
Character victim; Character victim;
if(type == MapleFamilyEntitlement.FAMILY_REUINION || type == MapleFamilyEntitlement.SUMMON_FAMILY) { if(type == FamilyEntitlement.FAMILY_REUINION || type == FamilyEntitlement.SUMMON_FAMILY) {
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(p.readString()); victim = c.getChannelServer().getPlayerStorage().getCharacterByName(p.readString());
if(victim != null && victim != c.getPlayer()) { if(victim != null && victim != c.getPlayer()) {
if(victim.getFamily() == c.getPlayer().getFamily()) { if(victim.getFamily() == c.getPlayer().getFamily()) {
MapleMap targetMap = victim.getMap(); MapleMap targetMap = victim.getMap();
MapleMap ownMap = c.getPlayer().getMap(); MapleMap ownMap = c.getPlayer().getMap();
if(targetMap != null) { if(targetMap != null) {
if(type == MapleFamilyEntitlement.FAMILY_REUINION) { if(type == FamilyEntitlement.FAMILY_REUINION) {
if(!FieldLimit.CANNOTMIGRATE.check(ownMap.getFieldLimit()) && !FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit()) if(!FieldLimit.CANNOTMIGRATE.check(ownMap.getFieldLimit()) && !FieldLimit.CANNOTVIPROCK.check(targetMap.getFieldLimit())
&& (targetMap.getForcedReturnId() == 999999999 || targetMap.getId() < 100000000) && targetMap.getEventInstance() == null) { && (targetMap.getForcedReturnId() == 999999999 || targetMap.getId() < 100000000) && targetMap.getEventInstance() == null) {
@@ -91,7 +91,7 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
c.sendPacket(PacketCreator.sendFamilyMessage(67, 0)); c.sendPacket(PacketCreator.sendFamilyMessage(67, 0));
} }
} }
} else if(type == MapleFamilyEntitlement.FAMILY_BONDING) { } else if(type == FamilyEntitlement.FAMILY_BONDING) {
//not implemented //not implemented
} else { } else {
boolean party = false; boolean party = false;
@@ -103,11 +103,11 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
case PARTY_EXP_2_30MIN: case PARTY_EXP_2_30MIN:
party = true; party = true;
isExp = true; isExp = true;
type = MapleFamilyEntitlement.SELF_EXP_2_30MIN; type = FamilyEntitlement.SELF_EXP_2_30MIN;
continue; continue;
case PARTY_DROP_2_30MIN: case PARTY_DROP_2_30MIN:
party = true; party = true;
type = MapleFamilyEntitlement.SELF_DROP_2_30MIN; type = FamilyEntitlement.SELF_DROP_2_30MIN;
continue; continue;
case SELF_DROP_2_30MIN: case SELF_DROP_2_30MIN:
duration = 30; duration = 30;
@@ -130,7 +130,7 @@ public final class FamilyUseHandler extends AbstractPacketHandler {
} }
} }
private boolean useEntitlement(MapleFamilyEntry entry, MapleFamilyEntitlement entitlement) { private boolean useEntitlement(MapleFamilyEntry entry, FamilyEntitlement entitlement) {
if(entry.useEntitlement(entitlement)) { if(entry.useEntitlement(entitlement)) {
entry.gainReputation(-entitlement.getRepCost(), false); entry.gainReputation(-entitlement.getRepCost(), false);
entry.getChr().sendPacket(PacketCreator.getFamilyInfo(entry)); entry.getChr().sendPacket(PacketCreator.getFamilyInfo(entry));

View File

@@ -5747,9 +5747,9 @@ public class PacketCreator {
public static Packet loadFamily(Character player) { public static Packet loadFamily(Character player) {
final OutPacket p = OutPacket.create(SendOpcode.FAMILY_PRIVILEGE_LIST); final OutPacket p = OutPacket.create(SendOpcode.FAMILY_PRIVILEGE_LIST);
p.writeInt(MapleFamilyEntitlement.values().length); p.writeInt(FamilyEntitlement.values().length);
for (int i = 0; i < MapleFamilyEntitlement.values().length; i++) { for (int i = 0; i < FamilyEntitlement.values().length; i++) {
MapleFamilyEntitlement entitlement = MapleFamilyEntitlement.values()[i]; FamilyEntitlement entitlement = FamilyEntitlement.values()[i];
p.writeByte(i <= 1 ? 1 : 2); //type p.writeByte(i <= 1 ? 1 : 2); //type
p.writeInt(entitlement.getRepCost()); p.writeInt(entitlement.getRepCost());
p.writeInt(entitlement.getUsageLimit()); p.writeInt(entitlement.getUsageLimit());
@@ -5816,8 +5816,8 @@ public class PacketCreator {
p.writeInt(f.getFamily().getLeader().getChrId()); // Leader ID (Allows setting message) p.writeInt(f.getFamily().getLeader().getChrId()); // Leader ID (Allows setting message)
p.writeString(f.getFamily().getName()); p.writeString(f.getFamily().getName());
p.writeString(f.getFamily().getMessage()); //family message p.writeString(f.getFamily().getMessage()); //family message
p.writeInt(MapleFamilyEntitlement.values().length); //Entitlement info count p.writeInt(FamilyEntitlement.values().length); //Entitlement info count
for (MapleFamilyEntitlement entitlement : MapleFamilyEntitlement.values()) { for (FamilyEntitlement entitlement : FamilyEntitlement.values()) {
p.writeInt(entitlement.ordinal()); //ID p.writeInt(entitlement.ordinal()); //ID
p.writeInt(f.isEntitlementUsed(entitlement) ? 1 : 0); //Used count p.writeInt(f.isEntitlementUsed(entitlement) ? 1 : 0); //Used count
} }