Compare commits

...

5 Commits

Author SHA1 Message Date
ShigemoriHakura
ec7a6aec50 remove unused import 2022-05-23 15:46:21 -07:00
ShiroSaki
0d5dc5ec31 Fix the bug that can't kill command-generated monsters
Command-generated monsters do not have spawnentry so we have to get data from getMonsterData
2022-05-23 15:46:21 -07:00
TurtleIdiot
f1211eca09 Added support for arch linux
Added support for arch linux and the pacman package manager used by arch
Please note that mongodb has to be fetched from the Arch User Repository and built due to licensing issues
2022-05-23 15:46:12 -07:00
TurtleIdiot
444463cab2 Removed broken/WIP elif 2022-05-23 15:46:12 -07:00
TurtleIdiot
1bf13d17f8 Added choice between stable and dev branch
Added a prompt to choose between downloading stable and development after the package manager validation and before the final confirmation prompt
2022-05-23 15:46:12 -07:00
4 changed files with 123 additions and 17 deletions

View File

@ -35,16 +35,38 @@ valid_ip() {
return $stat
}
# Checks for supported installer(s) (only apt-get for now :(, might add pacman in the future)
# Checks for supported installer(s) (only apt-get and pacman right now, might add more in the future)
if is_command apt-get ; then
echo -e "Supported package manager found\n"
echo -e "Supported package manager found (apt-get)\n"
GC_DEPS="mongodb openjdk-17-jre"
INSTALLER_DEPS="wget openssl unzip git"
SYSTEM="deb" # Debian-based (debian, ubuntu)
elif is_command pacman ; then
echo -e "supported package manager found (pacman)\n"
GC_DEPS="jre17-openjdk"
INSTALLER_DEPS="curl wget openssl unzip git base-devel" # curl is still a dependency here in order to successfully build mongodb
SYSTEM="arch" # Arch for the elitists :P
else
echo "No supported package manager found"
exit
fi
INSTALLER_DEPS="curl wget openssl unzip git"
GC_DEPS="mongodb openjdk-17-jre"
BRANCH="stable" # Stable by default
# Allows choice between stable and dev branch
echo "Please select the branch you wish to install"
echo -e "!!NOTE!!: stable is the recommended branch.\nDo *NOT* use development unless you have a reason to and know what you're doing"
select branch in "stable" "development" ; do
case $branch in
stable )
BRANCH="stable"
break;;
development )
BRANCH="development"
break;;
esac
done
echo "The following packages will have to be installed in order to INSTALL grasscutter:"
echo -e "$INSTALLER_DEPS \n"
@ -60,21 +82,95 @@ select yn in "Yes" "No" ; do
done
echo "Updating package cache..."
apt-get update -qq > /dev/null
case $SYSTEM in # More concise than if
deb ) apt-get update -qq;;
arch ) pacman -Syy;;
esac
# Starts installing dependencies
echo "Installing setup dependencies..."
apt-get -qq install $INSTALLER_DEPS -y > /dev/null
case $SYSTEM in # These are one-liners anyways
deb ) apt-get -qq install $INSTALLER_DEPS -y;;
arch ) pacman -Sq --noconfirm --needed $INSTALLER_DEPS > /dev/null;;
esac
echo "Done"
echo "Installing grasscutter dependencies..."
apt-get -qq install $GC_DEPS -y > /dev/null
case $SYSTEM in
deb) apt-get -qq install $GC_DEPS -y > /dev/null;;
arch ) pacman -Sq --noconfirm --needed $GC_DEPS > /dev/null;;
esac
# *sighs* here we go...
INST_ARCH_MONGO="no"
if [ $SYSTEM = "arch" ]; then
echo -e "-=-=-=-=-=--- !! IMPORTANT !! ---=-=-=-=-=-\n"
echo -e " Due to licensing issues with mongodb,\n it is no longer available on the official arch repositiries."
echo -e " In order to install mongodb,\n it needs to be fetched from the Arch User Repository.\n"
echo -e " As this script is running as root,\n a temporary user will need to be created to run makepkg."
echo -e " The temporary user will be deleted once\n makepkg has finished.\n"
echo -e " This will be handled automatically.\n"
echo -e "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"
echo -e "!!NOTE!!: Only select \"Skip\" if mongodb is already installed on this system"
echo "Do you want to continue?"
select yn in "Yes" "Skip" "No" ; do
case $yn in
Yes )
INST_ARCH_MONGO="yes"
break;;
No ) exit;;
Skip )
INST_ARCH_MONGO="no"
break;;
esac
done
fi
if [ $INST_ARCH_MONGO = "yes" ]; then
DIR=$(pwd)
# Make temp user
echo "Creating temporary user..."
TEMPUSER="gctempuser"
TEMPHOME="/home/$TEMPUSER"
useradd -m $TEMPUSER
cd $TEMPHOME
# Do the actual makepkg shenanigans
echo "Building mongodb... (this will take a moment)"
su $TEMPUSER<<EOF
mkdir temp
cd temp
git clone https://aur.archlinux.org/mongodb-bin.git -q
cd mongodb-bin
makepkg -s > /dev/null
exit
EOF
mv "$(find -name "mongodb-bin*.pkg.tar.zst" -type f)" ./mongodb-bin.pkg.tar.zst
cd $DIR
# Snatch the file to current working directory
mv "$TEMPHOME/mongodb-bin.pkg.tar.zst" ./mongodb-bin.pkg.tar.zst
chown root ./mongodb-bin.pkg.tar.zst
chgrp root ./mongodb-bin.pkg.tar.zst
chmod 775 ./mongodb-bin.pkg.tar.zst
echo "Installing mongodb..."
pacman -U mongodb-bin.pkg.tar.zst --noconfirm > /dev/null
rm mongodb-bin.pkg.tar.zst
echo "Starting mongodb..."
systemctl enable mongodb
systemctl start mongodb
echo "Removing temporary account..."
userdel -r $TEMPUSER
fi
echo "Done"
echo "Getting grasscutter..."
# Download and rename jar
wget -q --show-progress https://nightly.link/Grasscutters/Grasscutter/workflows/build/stable/Grasscutter.zip
wget -q --show-progress "https://nightly.link/Grasscutters/Grasscutter/workflows/build/$BRANCH/Grasscutter.zip"
echo "unzipping"
unzip -qq Grasscutter.zip
mv $(find -name "grasscutter*.jar" -type f) grasscutter.jar

View File

@ -216,7 +216,7 @@ public abstract class GameEntity {
// Check if dead
if (isDead) {
getScene().killEntity(this, 0);
getScene().killEntity(this, killerId);
}
}
}

View File

@ -5,6 +5,7 @@ import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.CodexAnimalData;
import emu.grasscutter.data.def.CodexReliquaryData;
import emu.grasscutter.game.entity.EntityMonster;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType;
@ -79,22 +80,21 @@ public class PlayerCodex {
}
public void checkAnimal(GameEntity target, CodexAnimalData.CodexAnimalUnlockCondition condition){
if(target.getEntityType() == 2){
var monsterId = target.getSpawnEntry().getMonsterId();
if(target instanceof EntityMonster){
var monsterId = ((EntityMonster)target).getMonsterData().getId();
var codexAnimal = GameData.getCodexAnimalDataMap().get(monsterId);
if(!getUnlockedAnimal().containsKey(monsterId)) {
if (codexAnimal != null) {
if(codexAnimal.getUnlockCondition() == condition){
if(codexAnimal.getUnlockCondition() == condition || codexAnimal.getUnlockCondition() == null){
getUnlockedAnimal().put(monsterId, 1);
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(3, monsterId));
}
}
}else{
getUnlockedAnimal().put(monsterId, getUnlockedAnimal().get(monsterId) + 1);
player.save();
}
player.save();
this.player.sendPacket(new PacketCodexDataUpdateNotify(3, monsterId));
}
}

View File

@ -386,9 +386,19 @@ public class Scene {
}
public void killEntity(GameEntity target, int attackerId) {
for (Player player : this.getPlayers()) {
player.getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
GameEntity attacker = getEntityById(attackerId);
//Check codex
if (attacker instanceof EntityClientGadget) {
var clientGadgetOwner = getEntityById(((EntityClientGadget) attacker).getOwnerEntityId());
if(clientGadgetOwner instanceof EntityAvatar) {
((EntityClientGadget) attacker).getOwner().getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
}
}
else if (attacker instanceof EntityAvatar) {
((EntityAvatar) attacker).getPlayer().getCodex().checkAnimal(target, CodexAnimalData.CodexAnimalUnlockCondition.CODEX_COUNT_TYPE_KILL);
}
// Packet
this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD));