ServerEvents.commandRegistry(event => {
	const { commands: Commands, arguments: Arguments } = event

	event.register(
		Commands.literal("setproperty_int")
        .requires(src => src.hasPermission(2))
        .then(Commands.argument('player', Arguments.PLAYER.create(event))
            .then(Commands.argument('property', Arguments.STRING.create(event))
                .then(Commands.argument('value', Arguments.INTEGER.create(event))
                    .executes(ctx => setPropInt(ctx))
                )
            )
        )
	)

	event.register(
		Commands.literal("getproperty")
        .requires(src => src.hasPermission(2))
        .then(Commands.argument('player', Arguments.PLAYER.create(event))
            .then(Commands.argument('property', Arguments.STRING.create(event))
                .executes(ctx => getPropInt(ctx))
            )
        )
	)

	event.register(
		Commands.literal("speedColor")
        .requires(src => src.hasPermission(2))
        .then(Commands.argument('value', Arguments.INTEGER.create(event))
            .executes(ctx => setSpeedColor(ctx))
        )
	)

	event.register(
		Commands.literal("vibeColor")
        .requires(src => src.hasPermission(2))
        .then(Commands.argument('value', Arguments.INTEGER.create(event))
            .executes(ctx => setVibeColor(ctx))
        )
	)

	event.register(
		Commands.literal("setSpeed")
        .requires(src => src.hasPermission(2))
        .then(Commands.argument('value', Arguments.INTEGER.create(event))
            .executes(ctx => setMaxSpeed(ctx))
        )
	)

    let setPropInt = (ctx) => {
        let player = Arguments.PLAYER.getResult(ctx, 'player')
        let property = Arguments.STRING.getResult(ctx, 'property')
        let value = Arguments.INTEGER.getResult(ctx, 'value')
    
        palladium.setProperty(player, property, value);
        // return 0 if fail
        return 1
    }

    let getPropInt = (ctx) => {
        let player = Arguments.PLAYER.getResult(ctx, 'player')
        let property = Arguments.STRING.getResult(ctx, 'property')
    
        player.tell(
            palladium.getProperty(player, property)
        )
        // return 0 if fail
        return 1
    }

    let setSpeedColor = (ctx) => {
        let val = Arguments.INTEGER.getResult(ctx, 'value')
    
        palladium.setProperty(ctx.source.player, 'arrzenhanced.speedColor', val)
        return 1
    }

    let setVibeColor = (ctx) => {
        let val = Arguments.INTEGER.getResult(ctx, 'value')
    
        palladium.setProperty(ctx.source.player, 'arrzenhanced.warpwave.color', val)
        return 1
    }

    let setMaxSpeed = (ctx) => {
        let val = Arguments.INTEGER.getResult(ctx, 'value')
    
        palladium.setProperty(ctx.source.player, 'arrzenhanced.maxSpeed', val)
        return 1
    }
})

