-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vehicles damages saving, repair kit, some bug fixes, bag wip
- Loading branch information
1 parent
9479e8f
commit 5a1c764
Showing
40 changed files
with
1,088 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 25 additions & 9 deletions
34
src/main/java/fr/yuki/YukiRPFramework/commands/CreateHouseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,49 @@ | ||
package fr.yuki.YukiRPFramework.commands; | ||
|
||
import fr.yuki.YukiRPFramework.character.CharacterState; | ||
import fr.yuki.YukiRPFramework.dao.HouseDAO; | ||
import fr.yuki.YukiRPFramework.manager.CharacterManager; | ||
import fr.yuki.YukiRPFramework.manager.HouseManager; | ||
import fr.yuki.YukiRPFramework.manager.WorldManager; | ||
import fr.yuki.YukiRPFramework.model.Account; | ||
import fr.yuki.YukiRPFramework.model.House; | ||
import net.onfirenetwork.onsetjava.Onset; | ||
import net.onfirenetwork.onsetjava.data.Vector; | ||
import net.onfirenetwork.onsetjava.entity.Player; | ||
import net.onfirenetwork.onsetjava.plugin.CommandExecutor; | ||
|
||
import java.sql.SQLException; | ||
|
||
public class CreateHouseCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(Player player, String s, String[] strings) { | ||
if(WorldManager.getPlayerAccount(player).getAdminLevel() == 0) return false; | ||
CharacterState state = CharacterManager.getCharacterStateByPlayer(player); | ||
if(state.getCurrentDisplayedLine3D() == null) return true; | ||
//if(state.getCurrentDisplayedLine3D() == null) return true; | ||
|
||
Vector firstLoc = state.getLastLocationsRequest().get(state.getLastLocationsRequest().size() - 1); | ||
Vector secondLoc = state.getLastLocationsRequest().get(state.getLastLocationsRequest().size() - 2); | ||
|
||
Account account = WorldManager.getPlayerAccount(player); | ||
House house = new House(); | ||
house.setAccountId(account.getId()); | ||
house.setPrice(100); | ||
house.setName("House"); | ||
house.setSx(state.getCurrentDisplayedLine3D().getsX()); | ||
house.setSy(state.getCurrentDisplayedLine3D().getsY()); | ||
house.setSz(state.getCurrentDisplayedLine3D().getsZ()); | ||
house.setEx(state.getCurrentDisplayedLine3D().geteX()); | ||
house.setEy(state.getCurrentDisplayedLine3D().geteY()); | ||
house.setEz(state.getCurrentDisplayedLine3D().geteZ()); | ||
house.setPrice(2500); | ||
house.setName("Maison"); | ||
house.setSx(firstLoc.getX()); | ||
house.setSy(firstLoc.getY()); | ||
house.setSz(firstLoc.getZ()); | ||
house.setEx(secondLoc.getX()); | ||
house.setEy(secondLoc.getY()); | ||
house.setEz(secondLoc.getZ()); | ||
HouseManager.getHouses().add(house); | ||
try { | ||
HouseDAO.insertHouse(house); | ||
} catch (SQLException throwables) { | ||
throwables.printStackTrace(); | ||
} | ||
Onset.print("House created id: " + house.getId()); | ||
player.sendMessage("House created id: " + house.getId()); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/fr/yuki/YukiRPFramework/commands/FreeHouseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package fr.yuki.YukiRPFramework.commands; | ||
|
||
import fr.yuki.YukiRPFramework.dao.HouseDAO; | ||
import fr.yuki.YukiRPFramework.manager.HouseManager; | ||
import fr.yuki.YukiRPFramework.manager.WorldManager; | ||
import fr.yuki.YukiRPFramework.model.House; | ||
import fr.yuki.YukiRPFramework.model.HouseItemObject; | ||
import net.onfirenetwork.onsetjava.entity.Door; | ||
import net.onfirenetwork.onsetjava.entity.Player; | ||
import net.onfirenetwork.onsetjava.plugin.CommandExecutor; | ||
|
||
import java.sql.SQLException; | ||
|
||
public class FreeHouseCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(Player player, String s, String[] args) { | ||
if(WorldManager.getPlayerAccount(player).getAdminLevel() == 0) return false; | ||
House house = HouseManager.getHouseAtLocation(player.getLocation()); | ||
if(house == null) { | ||
house = HouseManager.getHouseAtLocation(WorldManager.getNearestDoor(player.getLocation()).getLocation()); | ||
} | ||
if(house == null) return true; | ||
house.setAccountId(-1); | ||
for(Door door : house.getLine3D().getDoorsInside()) { | ||
door.close(); | ||
} | ||
for(HouseItemObject houseItemObject : house.getHouseItemObjects()) { | ||
houseItemObject.destroy(); | ||
} | ||
try { | ||
HouseDAO.saveHouse(house); | ||
} catch (SQLException throwables) { | ||
throwables.printStackTrace(); | ||
} | ||
|
||
player.sendMessage("This house is free now"); | ||
return true; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/fr/yuki/YukiRPFramework/commands/GiveHouseKeyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package fr.yuki.YukiRPFramework.commands; | ||
|
||
import fr.yuki.YukiRPFramework.manager.HouseManager; | ||
import fr.yuki.YukiRPFramework.manager.WorldManager; | ||
import fr.yuki.YukiRPFramework.model.Account; | ||
import fr.yuki.YukiRPFramework.model.House; | ||
import net.onfirenetwork.onsetjava.Onset; | ||
import net.onfirenetwork.onsetjava.entity.Player; | ||
import net.onfirenetwork.onsetjava.plugin.CommandExecutor; | ||
|
||
public class GiveHouseKeyCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(Player player, String s, String[] args) { | ||
Player playerTarget = Onset.getPlayers().stream().filter(x -> x.getId() == Integer.parseInt(args[0])) | ||
.findFirst().orElse(null); | ||
if(playerTarget == null) return true; | ||
|
||
House house = HouseManager.getHouseAtLocation(player.getLocation()); | ||
if(house == null) return true; | ||
if(!HouseManager.canBuildInHouse(player, house)) return true; | ||
Account targetAccount = WorldManager.getPlayerAccount(playerTarget); | ||
|
||
if(house.getAllowedPlayers().contains(targetAccount) || playerTarget.getId() == house.getAccountId()) return true; | ||
|
||
house.getAllowedPlayers().add(targetAccount.getId()); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.