Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #580 from rettichlp/hotfix/1-8-2
Browse files Browse the repository at this point in the history
hotfix/1-8-2
  • Loading branch information
rettichlp authored Feb 1, 2023
2 parents 4b79b85 + 3a429aa commit 8a4848f
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-oder-fehler.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ Füge gegebenenfalls Screenshots hinzu, um das Problem zu erläutern.

**Weitere Informationen (bitte ausfüllen):**
Minecraft Version: `1.12.2`
Addon Version: `1.8.1`
Addon Version: `1.8.2`
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'

version = '1.8.1'
version = '1.8.2'
group = 'com.rettichlp' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'UnicacityAddon'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@Mod(name = "UnicacityAddon", modid = "unicacityaddon", version = UnicacityAddon.VERSION, clientSideOnly = true, acceptedMinecraftVersions = "[1.12,1.12.2]")
public class UnicacityAddon extends LabyModAddon {

public static final String VERSION = "1.8.1";
public static final String VERSION = "1.8.2";
public static final Minecraft MINECRAFT = Minecraft.getMinecraft();
public static UnicacityAddon ADDON;
public static final Logger LOGGER = LogManager.getLogger();
Expand Down
108 changes: 68 additions & 40 deletions src/main/java/com/rettichlp/unicacityaddon/base/models/Data.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.rettichlp.unicacityaddon.base.models;

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.abstraction.AbstractionLayer;
import com.rettichlp.unicacityaddon.base.abstraction.UPlayer;
import com.rettichlp.unicacityaddon.base.enums.faction.DrugPurity;
import com.rettichlp.unicacityaddon.base.enums.faction.DrugType;
import com.rettichlp.unicacityaddon.base.enums.faction.Equip;
import joptsimple.internal.Strings;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import net.minecraft.util.math.BlockPos;

Expand All @@ -18,60 +15,89 @@
import java.util.List;
import java.util.Map;

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Getter
@Setter
public class Data {

@Builder.Default
private int bankBalance = 0;
private Integer bankBalance;
private String carInfo;
private Integer cashBalance;
private Map<DrugType, Map<DrugPurity, Integer>> drugInventoryMap;
private List<CoordlistEntry> coordlist;
private Map<Equip, Integer> equipMap;
private Long firstAidDate;
private Map<Integer, HouseData> houseDataMap;
private Integer jobBalance;
private Integer jobExperience;
private Integer payDayTime;
private Long plantFertilizeTime;
private Long plantWaterTime;
private Integer serviceCount;
private Integer timer;
private List<TodolistEntry> todolist;

public int getBankBalance() {
return bankBalance != null ? bankBalance : 0;
}

@Builder.Default
private String carInfo = Strings.EMPTY;
public String getCarInfo() {
return carInfo != null ? carInfo : Strings.EMPTY;
}

@Builder.Default
private int cashBalance = 0;
public int getCashBalance() {
return cashBalance != null ? cashBalance : 0;
}

@Builder.Default
private Map<DrugType, Map<DrugPurity, Integer>> drugInventoryMap = new HashMap<>();
public Map<DrugType, Map<DrugPurity, Integer>> getDrugInventoryMap() {
return drugInventoryMap != null ? drugInventoryMap : Collections.emptyMap();
}

@Builder.Default
private List<CoordlistEntry> coordlist = Collections.emptyList();
public List<CoordlistEntry> getCoordlist() {
return coordlist != null ? coordlist : Collections.emptyList();
}

@Builder.Default
private Map<Equip, Integer> equipMap = new HashMap<>();
public Map<Equip, Integer> getEquipMap() {
return equipMap != null ? equipMap : Collections.emptyMap();
}

@Builder.Default
private long firstAidDate = 0;
public long getFirstAidDate() {
return firstAidDate != null ? firstAidDate : 0;
}

@Builder.Default
private Map<Integer, HouseData> houseDataMap = new HashMap<>();
public Map<Integer, HouseData> getHouseDataMap() {
return houseDataMap != null ? houseDataMap : Collections.emptyMap();
}

@Builder.Default
private int jobBalance = 0;
public int getJobBalance() {
return jobBalance != null ? jobBalance : 0;
}

@Builder.Default
private int jobExperience = 0;
public int getJobExperience() {
return jobExperience != null ? jobExperience : 0;
}

@Builder.Default
private int payDayTime = 0;
public int getPayDayTime() {
return payDayTime != null ? payDayTime : 0;
}

@Builder.Default
private long plantFertilizeTime = -1;
public long getPlantFertilizeTime() {
return plantFertilizeTime != null ? plantFertilizeTime : 0;
}

@Builder.Default
private long plantWaterTime = -1;
public long getPlantWaterTime() {
return plantWaterTime != null ? plantWaterTime : 0;
}

@Builder.Default
private int serviceCount = 0;
public int getServiceCount() {
return serviceCount != null ? serviceCount : 0;
}

@Builder.Default
private int timer = 0;
public int getTimer() {
return timer != null ? timer : 0;
}

@Builder.Default
private List<TodolistEntry> todolist = Collections.emptyList();
public List<TodolistEntry> getTodolist() {
return todolist != null ? todolist : Collections.emptyList();
}

/**
* Adds the given value <code>i</code> to the <code>bankBalance</code>
Expand Down Expand Up @@ -140,6 +166,7 @@ public boolean removeCoordFromCoordlist(String name) {
* @see DrugPurity
*/
public void addDrugToInventory(DrugType drugType, DrugPurity drugPurity, int amount) {
UnicacityAddon.LOGGER.info("DrugInventoryInteraction: Added amount {} of DrugType {} with DrugPurity {} to inventory", amount, drugType, drugPurity);
if (drugType != null) {
Map<DrugPurity, Integer> drugPurityIntegerMap = drugInventoryMap.getOrDefault(drugType, new HashMap<>());
int oldAmount = drugPurityIntegerMap.getOrDefault(drugPurity, 0);
Expand All @@ -158,6 +185,7 @@ public void addDrugToInventory(DrugType drugType, DrugPurity drugPurity, int amo
* @see DrugPurity
*/
public void removeDrugFromInventory(DrugType drugType, DrugPurity drugPurity, int amount) {
UnicacityAddon.LOGGER.info("DrugInventoryInteraction: Removed amount {} of DrugType {} with DrugPurity {} from inventory", amount, drugType, drugPurity);
if (drugType != null) {
Map<DrugPurity, Integer> drugPurityIntegerMap = drugInventoryMap.getOrDefault(drugType, new HashMap<>());
int oldAmount = drugPurityIntegerMap.getOrDefault(drugPurity, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ public class PatternHandler {
* Pattern for name tag providing
*
* @see com.rettichlp.unicacityaddon.events.DeathsKillsEventHandler
* @see com.rettichlp.unicacityaddon.events.chatlog.ChatLogReceiveChatEventHandler
* @see com.rettichlp.unicacityaddon.events.faction.ContractEventHandler
* @see com.rettichlp.unicacityaddon.events.faction.badfaction.blacklist.BlacklistEventHandler
* @see com.rettichlp.unicacityaddon.events.faction.badfaction.blacklist.BlacklistModifyEventHandler
* @see com.rettichlp.unicacityaddon.events.faction.polizei.HQMessageEventHandler
* @see com.rettichlp.unicacityaddon.events.faction.polizei.WantedEventHandler
*/
public static final Pattern WANTED_LIST_ENTRY_PATTERN = Pattern.compile("^ {2}- (?:\\[UC])*(\\w+) \\| (\\d+) WPS \\((.+)\\)(| \\| AFK)$");
public static final Pattern WANTED_LIST_PATTERN = Pattern.compile("^ {2}- (?:\\[UC])*(\\w+) \\| (\\d+) WPS \\((.+)\\)(| \\| AFK)$");
public static final Pattern WANTED_GIVEN_REASON_PATTERN = Pattern.compile("^HQ: Gesuchter: (?:\\[UC])*(\\w+)\\. Grund: (.+)$");
public static final Pattern WANTED_REASON = Pattern.compile("^HQ: Fahndungsgrund: (.+) \\| Fahndungszeit: (.+)\\.$");
public static final Pattern WANTED_GIVEN_POINTS_PATTERN = Pattern.compile("^HQ: (?:\\[UC])*(\\w+)'s momentanes WantedLevel: (\\d+)$");
Expand All @@ -103,6 +104,7 @@ public class PatternHandler {
public static final Pattern CONTRACT_SET_PATTERN = Pattern.compile("^\\[Contract] Es wurde ein Kopfgeld auf (?:\\[UC])*(\\w+) \\(\\d+\\$\\) ausgesetzt\\.$");
public static final Pattern CONTRACT_REMOVED_PATTERN = Pattern.compile("^\\[Contract] (?:\\[UC])*\\w+ hat (?:\\[UC])*(\\w+) von der Contract Liste gelöscht\\. \\[-\\d+]$" +
"|^\\[Contract] (?:\\[UC])*(\\w+) hat (?:\\[UC])*(\\w+) getötet\\. Kopfgeld: \\d+\\$");
public static final Pattern CONTRACT_LIST_PATTERN = Pattern.compile("^ - (?:\\[UC])*(?<name>\\w+) \\[(?<money>\\d+)\\$](| \\(AFK\\))$");

/**
* Pattern for job interaction
Expand Down Expand Up @@ -309,16 +311,4 @@ public class PatternHandler {
*/
public static final Pattern BUY_INTERRUPTED_PATTERN = Pattern.compile("^Verkäufer: (Tut (uns|mir) Leid|Verzeihung), unser Lager ist derzeit leer\\.$" +
"|^Verkäufer: Dieses Produkt kostet \\d+\\$\\.$" + "|^Verkäufer: Du hast leider nicht genug Geld dabei\\.$");

/**
* Pattern for Duty Check
*
* @see com.rettichlp.unicacityaddon.events.faction.DutyEventHandler
*/
public static final Pattern DUTY_JOIN_PATTERN = Pattern.compile("^Du bist nun als Arzt im Dienst!$" +
"|^Du bist nun im FBI Dienst!$" +
"|^Du bist nun im Polizei Dienst!$");
public static final Pattern DUTY_LEAVE_PATTERN = Pattern.compile("^Du bist nun nicht mehr als Arzt Dienst!$" +
"|^Du bist nun nicht mehr im FBI Dienst!$" +
"|^Du bist nun nicht mehr im Polizei Dienst!$");
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.rettichlp.unicacityaddon.base.abstraction.AbstractionLayer;
import com.rettichlp.unicacityaddon.base.abstraction.UPlayer;
import com.rettichlp.unicacityaddon.base.builder.TabCompletionBuilder;
import com.rettichlp.unicacityaddon.base.manager.FileManager;
import com.rettichlp.unicacityaddon.base.registry.annotation.UCCommand;
import com.rettichlp.unicacityaddon.base.text.ColorCode;
import com.rettichlp.unicacityaddon.base.text.Message;
Expand All @@ -23,8 +24,6 @@
@UCCommand
public class ServiceCountCommand implements IClientCommand {

public static int serviceCount;

@Override
@Nonnull
public String getName() {
Expand All @@ -51,17 +50,15 @@ public boolean checkPermission(@Nonnull MinecraftServer server, @Nonnull IComman
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) {
UPlayer p = AbstractionLayer.getPlayer();
if (args.length > 0) {
if (!args[0].equalsIgnoreCase("reset"))
return;
serviceCount = 0;
if (args.length > 0 && args[0].equalsIgnoreCase("reset")) {
FileManager.DATA.setServiceCount(0);
p.sendInfoMessage("Servicecount wurde zurückgesetzt.");
return;
}

Message.getBuilder().prefix().space()
.of("Du hast bereits").color(ColorCode.GRAY).advance().space()
.of("" + serviceCount).color(ColorCode.DARK_AQUA).advance().space()
.of(String.valueOf(FileManager.DATA.getServiceCount())).color(ColorCode.DARK_AQUA).advance().space()
.of("Notrufe bearbeitet.").color(ColorCode.GRAY).advance().sendTo(p.getPlayer());
}

Expand All @@ -78,10 +75,6 @@ public boolean isUsernameIndex(@Nonnull String[] args, int index) {
return false;
}

public static void addService() {
serviceCount++;
}

@Override
public boolean allowUsageWithoutPrefix(ICommandSender sender, String message) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
handleNameTag();
handleBombTimer();
handleTimer();
handleCustomSeconds();
}

// 3 SECONDS
Expand All @@ -64,26 +65,17 @@ public void onTick(TickEvent.ClientTickEvent event) {
if (currentTick % 1200 == 0) {
handlePayDay();
}

// CUSTOM SECONDS
String intervalString = ConfigElements.getRefreshDisplayNamesInterval();
int interval = 5 * 20; // every 5 seconds
if (MathUtils.isInteger(intervalString))
interval = Integer.parseInt(intervalString) * 20;
if (currentTick % interval == 0)
handleNameTagSyncDisplayName();
}
}

private void handleReinforcementScreenshot() {
if (ReinforcementEventHandler.activeReinforcement < 0 || ReinforcementEventHandler.activeReinforcement + 15 != currentTick)
return;

try {
File file = FileManager.getNewActivityImageFile("reinforcement");
HotkeyEventHandler.handleScreenshot(file);
} catch (IOException e) {
throw new RuntimeException(e);
if (ReinforcementEventHandler.activeReinforcement >= 0 && ReinforcementEventHandler.activeReinforcement + 15 == currentTick) {
try {
File file = FileManager.getNewActivityImageFile("reinforcement");
HotkeyEventHandler.handleScreenshot(file);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

Expand All @@ -106,27 +98,20 @@ private void handleNameTag() {
String name = entityItem.getCustomNameTag();
String playerName = name.substring(3);

if (!Syncer.PLAYERFACTIONMAP.containsKey(name.substring(3)))
return;
if (name.contains("◤"))
return; // already edited
if (Syncer.PLAYERFACTIONMAP.containsKey(playerName) && !name.contains("◤")) {
String prefix = NameTagEventHandler.getPrefix(playerName, true);
String factionInfo = NameTagEventHandler.getFactionInfo(playerName);

String prefix = NameTagEventHandler.getPrefix(playerName, true);
String factionInfo = NameTagEventHandler.getFactionInfo(playerName);
if (name.startsWith(ColorCode.DARK_GRAY.getCode())) { // non-revivable
entityItem.setCustomNameTag(ColorCode.DARK_GRAY.getCode() + "✟" + playerName + factionInfo);
return;
}

if (name.startsWith(ColorCode.DARK_GRAY.getCode())) { // non-revivable
entityItem.setCustomNameTag(ColorCode.DARK_GRAY.getCode() + "✟" + playerName + factionInfo);
return;
entityItem.setCustomNameTag(prefix + "✟" + playerName + factionInfo);
}

entityItem.setCustomNameTag(prefix + "✟" + playerName + factionInfo);
});
}

private void handleNameTagSyncDisplayName() {
NameTagEventHandler.refreshAllDisplayNames();
}

private void handleBombTimer() {
if (!BombTimerModule.isBomb)
return;
Expand All @@ -146,6 +131,15 @@ private void handleTimer() {
}
}

private void handleCustomSeconds() {
if (UnicacityAddon.isUnicacity() && UnicacityAddon.ADDON.getConfig() != null) {
String intervalString = ConfigElements.getRefreshDisplayNamesInterval();
if (currentTick % (MathUtils.isInteger(intervalString) ? Integer.parseInt(intervalString) * 20 : 5 * 20) == 0) {
NameTagEventHandler.refreshAllDisplayNames();
}
}
}

private void handleScoreboardCheck() {
Scoreboard scoreboard = AbstractionLayer.getPlayer().getWorldScoreboard();
CarEventHandler.checkTank(scoreboard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.rettichlp.unicacityaddon.UnicacityAddon;
import com.rettichlp.unicacityaddon.base.registry.annotation.UCEvent;
import com.rettichlp.unicacityaddon.base.text.PatternHandler;
import com.rettichlp.unicacityaddon.commands.ChatLogCommand;
import net.labymod.api.events.MessageReceiveEvent;

Expand All @@ -13,8 +14,8 @@ public class ChatLogReceiveChatEventHandler implements MessageReceiveEvent {

@Override
public boolean onReceive(String s, String s1) {
if (UnicacityAddon.isUnicacity())
ChatLogCommand.chatLogMap.put(System.currentTimeMillis(), "[CHAT] " + s);
if (UnicacityAddon.isUnicacity() && !PatternHandler.BLACKLIST_LIST_PATTERN.matcher(s1).find() && !PatternHandler.CONTRACT_LIST_PATTERN.matcher(s1).find() && !PatternHandler.WANTED_LIST_PATTERN.matcher(s1).find())
ChatLogCommand.chatLogMap.put(System.currentTimeMillis(), "[CHAT] " + s1);
return false;
}
}
Loading

0 comments on commit 8a4848f

Please sign in to comment.